The usage of "colorspace( )"
8 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 1 Apr 2012
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 Comments
Image Analyst
on 4 Apr 2012
Since my demo code worked and colorspace() isn't, I suggest you contact the author of colorspace().
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!