I am having some trouble with finding documentation of visualization of LAB color space in matplotlib
. I got the channels separated. Here is my code for that:
img = cv2.imread("image.jpg")
img_LAB = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
l,a,b = cv2.split(img_LAB)
I don't have any problems with displaying the L channel as it is just grayscale.
plt.imshow(l,cmap='gray')
however I cannot find any colormaps for a and b. "a" is red-green and "b" is blue-yellow and matplotlib doesn't have cmap option for them. If I try to directly imshow
the channels, it gives RGB image. I tried creating a red-green channel. don't know if this is correct:
cdict1 = {'red': ((0.0, 0.0, 0.0),
(0.5, 0.0, 1.0),
(1.0, 0.1, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(1.0, 0.0, 0.0)),
'green': ((0.0, 0.0, 0.1),
(0.5, 1.0, 0.0),
(1.0, 0.0, 0.0))
}
red_green = LinearSegmentedColormap("RdGn",cdict1)
I am also having confusion regarding the cmap dict. what does the two y values signify? the documentations do have clear explanation. I don't know if my cmap is correct. But I still don't get how to display b channel. What can be the better way of doing this?