Display L*A*B space channels separately

조회 수: 20 (최근 30일)
Stephani Kanga
Stephani Kanga 2021년 12월 1일
답변: Image Analyst 2021년 12월 1일
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