Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting from RGB to LAB yields strange results, but vice versa works fine

I have a LAB image that I want to convert to RGB. 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 an LAB image and tried to reverse the process, first converting said image to RGB (which worked fine) and then convert the result back to LAB (didn't work).

Converting from RGB to LAB yields strange results, but vice versa works fine

I have a LAB RGB image that I want to convert to RGB. 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 an 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).