imgaug icon indicating copy to clipboard operation
imgaug copied to clipboard

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

Open jiayinghoutonghua opened this issue 7 years ago • 6 comments

jiayinghoutonghua avatar Mar 21 '18 08:03 jiayinghoutonghua

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.

aleju avatar Mar 21 '18 18:03 aleju

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

jiayinghoutonghua avatar Mar 22 '18 02:03 jiayinghoutonghua

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.

aleju avatar Mar 22 '18 17:03 aleju

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

jiayinghoutonghua avatar Mar 23 '18 05:03 jiayinghoutonghua

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.

aleju avatar Mar 23 '18 17:03 aleju

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!

arnabiswas avatar Mar 19 '22 19:03 arnabiswas