how to extract the a and b channel from the lab color space

1 view (last 30 days)
how to extract the a and b channel from the lab color space

Answers (2)

Geoff Hayes
Geoff Hayes on 14 Feb 2015
Sathiya - if you have access to the Image Processing Toolbox, try using the rgb2lab function which will convert your RGB image to L*a*b*. For example,
rgbImg = imread('someImage.jpg');
labImg = rgb2lab(rgbImg);
Then, to get the a* and b* channels, just access the third dimension of the labImg as
% get the a channel
aChannel = labImg(:,:,2);
% get the b channel
bChannel = labImg(:,:,3);
Try the above and see what happens!

Image Analyst
Image Analyst on 14 Feb 2015
Attached is a very useful demo, an adaptation of a demo the leader of the Image Processing Team at the Mathworks sent to me. It gets LAB and HSV and then displays the colors for a variety of L and V values. Here's two of the images it produces. LAB is useful if you want to get color differences but is probably not as good as HSV if you want to do color segmentation. I do all my color segmentation in hsv color space. Notice how the colors seems to change depending on the L level (like blue going to cyan), but how the colors don't change in HSV space. So if you want to get blue, you'll have to take L into account in LAB color space (in fact there isn't even any pure deep blue for higher L values), but if you want blue and you use HSV color space, you do not need to worry about V.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!