The usage of "colorspace( )"
8 次查看(过去 30 天)
显示 更早的评论
I have used the function “colorspace( )” which can be found in the page of " http://www.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations " as follows:
rgb = imread('peppers.png');
C = makecform('srgb2lab');
lab = applycform(rgb,C);
lab_2 = colorspace('lab<-rgb', rgb);
lab_3 = lab2uint8(lab_2);
I was surprised that the values in lab and lab_3 were quite different. I want to know the mistake in my code or my logical.
Thanks a lot.
0 个评论
回答(1 个)
Image Analyst
2012-4-1
I don't have that File Exchange file and didn't try it. Maybe it wants double. Try this code:
clc;
rgb = imread('peppers.png');
C = makecform('srgb2lab');
lab = applycform(double(rgb)/255,C);
lChannel = lab(:,:,1);
aChannel = lab(:,:,2);
bChannel = lab(:,:,3);
lab_2_uint8 = colorspace('lab<-rgb', rgb);
lChannel2u = lab_2(:,:,1);
aChannel2u = lab_2(:,:,2);
bChannel2u = lab_2(:,:,3);
lab_2_double = colorspace('lab<-rgb', double(rgb)/255);
lChannel2d = lab_2(:,:,1);
aChannel2d = lab_2(:,:,2);
bChannel2d = lab_2(:,:,3);
% Now compute differences between them
lDiffu = lChannel2u - lChannel;
aDiffu = aChannel2u - aChannel;
bDiffu = bChannel2u - bChannel;
lDiffd = lChannel2d - lChannel;
aDiffd = aChannel2d - aChannel;
bDiffd = bChannel2d - bChannel;
% lab_3 = lab2uint8(lab_2);
Let me know if that reveals anything.
2 个评论
Image Analyst
2012-4-4
Since my demo code worked and colorspace() isn't, I suggest you contact the author of colorspace().
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!