Code covered by the BSD License  

Highlights from
Consistent imaging with consumer cameras

image thumbnail

Consistent imaging with consumer cameras

by

 

08 Jul 2013 (Updated )

Accurate color capture using consumer cameras.

spectra2XYZ(reflectance,light,CMF)
function XYZ = spectra2XYZ(reflectance,light,CMF)
%
% XYZ = SPECTRA2XYZ(REFLECTANCE,LIGHT,CMF)
% 
% REFLECTANCE: REFLECTANCE SPECTRUM OF FEATURE, 1XN
% LIGHT: LIGHT SPECTRUM OF FEATURE, 1XN
% CMF: COLOR MATCHING FUNCTIONS, HUMAN OR CAMERA, 3XN
% XYZ: TRISTIMULUS VALUES CORRESPONDING TO REFLECTANCE SPECTRUM UNDER THE
% PARTICULAR LIGHT SPECTRUM
%
% ************************************************************************
% If you use this code, please cite the following paper:
%
%
% <paper>
%
% ************************************************************************
% For questions, comments and bug reports, please use the interface at
% Matlab Central/ File Exchange. See paper above for details.
% ************************************************************************



assert(size(reflectance,2)==size(light,2),'reflectance and light spectra must be the same length');
assert(size(reflectance,2)==size(CMF,2),'CMF must be the same length as light and reflectance spectra');

radiance = (reflectance.*light)./(CMF(2,:)*light');
radiance(isnan(radiance)) = 0;
XYZ = radiance*CMF';

Contact us