Page 78 - Computational Colour Science Using MATLAB
P. 78
IMPLEMENTATIONS AND EXAMPLES 65
elseif strcmp(’f7___31’, obs)
white=[95.041 100.00 108.747];
elseif strcmp(’f9___64’, obs)
white=[103.863 100.00 65.607];
elseif strcmp(’f9___31’, obs)
white=[100.962 100.00 64.350];
else
disp(’unknown option obs’);
disp(’use d65___64 for D65 and 1964 observer’); return;
end
dim = size(xyz);
if (dim(1) == 1) | (dim(2) == 1)
xyz = xyz(:)’; % force to be a row matrix
else
disp(’xyz must be a row matrix’);
return;
end
% compute u’ v’ for sample
uprime = 4*xyz(1)/(xyz(1) + 15*xyz(2) + 3*xyz(3));
vprime = 9*xyz(2)/(xyz(1) + 15*xyz(2) + 3*xyz(3));
% compute u’ v’ for white
uprimew = 4*white(1)/(white(1) + 15*white(2) + . . .
3*white(3));
vprimew = 9*white(2)/(white(1) + 15*white(2) + . . .
3*white(3));
if (xyz(2)/white(2) > 0.008856)
luv(1) = 116*(xyz(2)/white(2))^(1/3) - 16;
else
luv(1) = 903.3*(xyz(2)/white(2));
end
luv(2) = 13*luv(1)*(uprime - uprimew);
luv(3) = 13*luv(1)*(vprime - vprimew);
A single function car2pol has been provided to compute polar coordinates
from cartesian coordinates. If the input to this function is a* and b*, then the
output is C* and h , whereas if the input is u* and v*, then the output is C* and
ab
uv
ab
h .
uv