Display L*A*B space channels separately

18 次查看(过去 30 天)
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.

采纳的回答

DGM
DGM 2021-12-1
编辑:DGM 2021-12-1
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)

更多回答(1 个)

Image Analyst
Image Analyst 2021-12-1
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')

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by