필터 지우기
필터 지우기

RGB to LAB converting to a weird colour

조회 수: 1 (최근 30일)
Noah Noah
Noah Noah 2022년 3월 15일
편집: DGM 2022년 3월 16일
I have an issue convering my RGB image to Lab: The following is my output of the ImgtoLab
Code
c= makecform("srgb2lab")
ImgtoLab = applycform(dilatedimg,c)
  댓글 수: 1
Jan
Jan 2022년 3월 15일
Please post the input data and a minimal working code to reproduce the problem. Of course a Lab color image looks different, if you display it on an RGB device.

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2022년 3월 16일
편집: DGM 2022년 3월 16일
Image viewing/reading/writing tools are generally only capable of handling either single-channel grayscale images, single-channel indexed color images, or RGB images. For grayscale and RGB images, the tools expect data to be scaled according to their class. For floating-point data, that means that all image data is within [0 1].
You have a floating-point LAB image. This will be outside the expected data range for what imshow() expects, and so everything will be clipped severely. The image will be blindly rendered as if it were RGB, since there is no metadata that tells imshow() what colorspace is in use, and imshow() doesn't have the functionality to do anything about it even if it knew what it was. The only thing it knows is that it has a MxNx3 floating point array.
A = imread('patchchart2.png');
A = im2double(A);
dilatedimg = imdilate(A,ones(4));
c= makecform("srgb2lab");
ImgtoLab = applycform(dilatedimg,c);
% data range per channel
[min(ImgtoLab(:,:,1),[],'all') max(ImgtoLab(:,:,1),[],'all')]
ans = 1×2
32.8207 99.9988
[min(ImgtoLab(:,:,2),[],'all') max(ImgtoLab(:,:,2),[],'all')]
ans = 1×2
-60.7268 68.0733
[min(ImgtoLab(:,:,3),[],'all') max(ImgtoLab(:,:,3),[],'all')]
ans = 1×2
-80.3756 77.8138
imshow(ImgtoLab)
Depending on what you're trying to do, a means of visualization like what @yanqi liu shows might be more useful.
For what it's worth, I don't know why you aren't just using rgb2lab() (maybe you want to use a different whitepoint or profile?)

추가 답변 (1개)

yanqi liu
yanqi liu 2022년 3월 16일
img = imread('football.jpg');
jmg = rgb2lab(img);
figure;
subplot(2, 2, 1); imshow(img, []); title('origin');
subplot(2, 2, 2); imshow(jmg(:,:,1), []); title('L');
subplot(2, 2, 3); imshow(jmg(:,:,2), []); title('A');
subplot(2, 2, 4); imshow(jmg(:,:,3), []); title('B');

카테고리

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