Converting from RGB to LAB yields strange results, but vice versa works fine
I have a RGB image that I want to convert to LAB. When trying to convert an image from LAB colour space to RGB it works fine, but when I want to convert RGB->LAB, the luminance value for all pixels is 100, while the ab values for all pixels are 0. Anyone know why? This is the code I am using:
lab_img = cv2.cvtColor(rgb_img.astype(np.float32), cv2.COLOR_RGB2LAB)
I actually had a copy of a LAB image and tried to reverse the process, first converting the said image to RGB (which worked fine) and then convert the result back to LAB (didn't work).
I didn't test your code, but I don't understand why are you transforming your image to float...?
In float format, 0 is considered black, 1 is white. Maybe that's why the luminosity channel is saturated.