aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.38k stars 2.44k forks source link

how to add motion_blur() to this source code? thank you! #111

Open jiayinghoutonghua opened 6 years ago

aleju commented 6 years ago

There is no augmenter yet that adds motion blur, if that is what you mean. If you want to build your own one and have a motion blur function ready, you could maybe look at GaussianBlur in imgaug/augmenters/blur.py, which I guess would be the most similar augmenter. Just copy-paste it and change the necessary functions.

jiayinghoutonghua commented 6 years ago

thank you,i have made this similar functions,but i just want to blur part region of image,

aleju commented 6 years ago

If you already have the function, you could use Lambda to add it to a sequential, e.g.:

def func_images(images, random_state, parents, hooks):
    images[:, ::2, :, :] = 0
    return images

def func_keypoints(keypoints_on_images, random_state, parents, hooks):
    return keypoints_on_images

seq = iaa.Sequential([
    iaa.Lambda(
        func_images=func_images,
        func_keypoints=func_keypoints
    )
])

This replaces every second row in images with black pixels and leaves keypoints unchanged. If you don't have keypoints, you can just set func_keypoints=None.

jiayinghoutonghua commented 6 years ago

you are so nice sincerely,thank you. but can you add one motion_blur function to your source code?

aleju commented 6 years ago

Last time I looked into that I couldn't find any preimplemented motion blur functions in python or good implementations on how to implement one in pseudocode. If I find anything like that, I can add it to the library.

arnabiswas commented 2 years ago

I think motion blur function has since been added to the repository and works great. The only issue is that even as the object in the image rightly appears to move after the application of motion blur there is no corresponding transformation of keypoints or heatmaps from original labels possible at this moment. I am looking into implementing this right now, but just wanted to ask if people are aware of this issue? Thank you!