I want to use MATLAB to convert rgb to Lab using AdobeRGB.icc. I know how to convert using srgb.icc.
cform = makecform('srgb2lab');
lab = applycform(rgb, cform);
However, I don't know how to use AdobeRGB.icc to convert. First, we can read icc profile by:
p = iccread('AdobeRGB.icc');
But I don't know how to continue. Any suggestions? Thanks!
Have a look at p
- does it contain a field "MatTRC"? (I hope so!)
This is most likely a rgb2xyz
transform. (Check p.Header.ConnectionSpace
)
Actually, if you look with edit makecform
and dig into the code a little, you will see that if you call makecform
with an input such as 'srgb2lab'
they just create two transforms, 'srgb2xyz'
and 'xyz2lab'
, and then apply them in sequence. So we can do the same - using your icc profile for the rgb2xyz
part, and the built-in for the xyz2lab
part:
% 'forward' is rgb2xyz
cform1 = makecform('mattrc', p, 'Direction', 'forward');
cform2 = makecform('xyz2lab');
xyz = applycform(rgb, cform1);
lab = applycform(xyz, cform2);