aleju / imgaug

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

how to use imgaug to aug single image just one time? #825

Closed wolfryu closed 2 years ago

wolfryu commented 2 years ago

I run this code:

from imgaug import augmenters as iaa
import imgaug as ia
import cv2
ia.seed(42)
image = cv2.imread("test.png")  # two example images
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
alpha_r = [0.3,0.5,1]
for a in alpha_r:
    rotate = iaa.Canny(alpha=a)
    image_aug = rotate(image=image)
    cv2.imwrite("canny_a"+str(a)+".png", image_aug)

The code is used to aug image just one time with different canny alpha setting, but the output is not what I want, it looks like iaa is working on the last image all the time. canny_a0.3.png is OK. canny_a0.5.png is not OK, looks like not aug on image, but aug on canny_a0.3.png. canny_a1.png is not OK, a black image shows.

how can I aug one image just one time? Thank you!