


Gateway routine that returns various color space transformation matrices
result = colorTransformMatrix(matrixtype,spacetype)
The routine returns a 3x3 color matrix, MAT, suitable for use with
rgbLinearTransform, to convert an NxMx3 color image from one color
space to another.
Suppose a point is represented by the row vector, p = [R,G,B].
The matrix transforms each color point, p, to an output vector pT
This routine works with colorTransformMatrix, which provides color transformation matrices
so that the call
T = colorTransformMatrix('lms2xyz');
xyzImage = rgbLinearTransform(lmsImage,T)
returns an NxMx3 xyz Image as expected
matrixtypes are:
'lms2opp' -- cone coordinate to opponent (Poirson & Wandell 1993)
'opp2lms' -- inverse of the above matrix
'xyz2opp' -- xyz to opponent (CIE1931 2 degree XYZ)
'opp2xyz' -- inverse of the above matrix
'hpeCones2xyz' -- Hunt-Pointer-Estevez transformation from cone
to XYZ, normalized for D65 (lms=[100 100 100] for D65).
'xyz2hpeCones' -- inverse of hpeCones2xyz.
'xyz2yiq' -- convert from XYZ to YIQ
'yiq2xyz' -- inverse of the abvoe matrix
'rgb2yuv' -- convert from RGB to YUV (YCbCr) for JPEG compression
'yuv2rgb' -- inverse of the above matrix
'xyz2srgb' -- from XYZ to sRGB values
'srgb2xyz' -- inverse of the above matrix
(the above are not dependent on device calibration)
We added lrgb, which does the same as srgb, to be a little
clearer about the fact that this matrix is really in linear (0,1) space,
not in the framebuffer (0,255) nonlinear space.
'xyz2lrgb' -- from XYZ to lRGB values
'lrgb2xyz' -- inverse of the above matrix
'cmy2rgb' -- converts cyan, magenta, yellow to RGB
Examples:
A red stimulus
p = [70,70,40]; chromaticity(p)
T = colorTransformMatrixNew('xyz2lrgb')
p*T
(luminance, red-green, blue-yellow)
T = colorTransformMatrixNew('xyz2opp')
p*T
Make an image of the XYZ matching functions:
XYZ = vcReadSpectra('XYZ.mat',370:730); imXYZ = zeros(361,20,3);
for ii=1:3, imXYZ(:,:,ii) = repmat(XYZ(:,ii),1,20); end
T = colorTransformMatrix('xyz2srgb');
imRGB = imageLinearTransform(imXYZ,T);
imagescRGB(imRGB);
Copyright ImagEval Consultants, LLC, 2003.