aleju / imgaug

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

WithColorspace doesn't support HLS #165

Open robert405 opened 5 years ago

robert405 commented 5 years ago

Hi,

I was trying to change the brightness of an image and when i used WithColorspace with the target space HLS it give me the error : KeyError: 'HLS2RGB'.

This code work fine :

image = cv2.imread(imagePath) lighter = iaa.WithColorspace(to_colorspace="HSV", from_colorspace="RGB", children=iaa.WithChannels(1, iaa.Multiply((1.5)))) img = lighter.augment_image(image)

And this code give the error :

image = cv2.imread(imagePath) lighter = iaa.WithColorspace(to_colorspace="HLS", from_colorspace="RGB", children=iaa.WithChannels(1, iaa.Multiply((1.5)))) img = lighter.augment_image(image)

You can see that the only difference is the "HLS" colorspace!

And this is the stack trace :

Traceback (most recent call last): line 22, in img = lighter.augment_image(image) line 323, in augment_image return self.augment_images([image], hooks=hooks)[0] line 431, in augment_images hooks=hooks line 100, in _augment_images ).augment_images(images=result) line 431, in augment_images hooks=hooks line 320, in _augment_images from_to_var = ChangeColorspace.CV_VARS[from_to_var_name] KeyError: 'HLS2RGB'

Just to let you know! Keep up the good work!

aleju commented 5 years ago

Thanks for the info. Added it to the TODO list. The key is indeed missing. Though BGR2HLS is available, so you could combine two WithColorspace to go from RGB to BGR and then HLS if you really need it.

robert405 commented 5 years ago

No, I don't need it that much, I was just exploring your lib and noticed that. After a couple experiments, I can say you did a great job, thank for sharing your hard work!