Display L*A*B space channels separately

18 views (last 30 days)
I want to display the component images of a true colour image in L*A*B space. Although, i don't want to show them all as grayscale images. I want the L* image to show the brightness(so this is going to be a grayscale image) and a* and b* images should show the corresponding hues.

Accepted Answer

DGM
DGM on 1 Dec 2021
Edited: DGM on 1 Dec 2021
Lemme try that again...
RGB = imread('peppers.png');
[L A B] = imsplit(rgb2lab(RGB));
Lfill = 50*ones(size(L)); % pick some L level for representing A,B
Zfill = zeros(size(L));
Lvis = mat2gray(L);
Avis = lab2rgb(cat(3,Lfill,A,Zfill));
Bvis = lab2rgb(cat(3,Lfill,Zfill,B));
figure; imshow(Lvis)
figure; imshow(Avis)
figure; imshow(Bvis)

More Answers (1)

Image Analyst
Image Analyst on 1 Dec 2021
Try this:
rgbImage = imread('peppers.png');
imshow(rgbImage);
labImage = rgb2lab(rgbImage);
[lImage, aImage, bImage] = imsplit(labImage);
% Show the L channel
subplot(3, 1, 1);
imshow(lImage, []);
impixelinfo;
title('L image')
% Create red to green colormap.
ramp = linspace(0, 1, 256)';
z = zeros(size(ramp))
colormapRG = [ramp, flipud(ramp), z];
% Create blue to yellow colormap.
colormapBY = [ramp, ramp, flipud(ramp)];
% Show the A channel
subplot(3, 1, 2);
imshow(aImage, 'Colormap',colormapRG);
impixelinfo;
caxis([-128, 127]);
title('A image')
% Show the B channel
subplot(3, 1, 3);
imshow(bImage, 'Colormap',colormapBY);
impixelinfo;
caxis([-128, 127]);
title('B image')

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!