aleju / imgaug

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

imgaug converts grayscale image to RGB! #780

Closed jayanthante closed 3 years ago

jayanthante commented 3 years ago

I am trying to add some augmentations to some of my grayscale images using


def augment_it(img):
    seq = iaa.OneOf( [
    iaa.ScaleX((0.7,1.3), cval=255),
    iaa.CoarseDropout(0.02, size_percent=(0.02,0.2)) #I want the new pixels to be white in colour. 
    ])
    # aug_img = iaa.Grayscale(1.0)
    aug_img = seq(image=img)
    return aug_img

I use this as the preprocessing function with imagedatagenerator in keras.

But this function returns me an RGB image with 3 channels (the coarse dropout being in any of the colours)

What should I do to keep my images grayscale?