MATLAB: How to transform wavelength data into RGB data when using the Image Processing Toolbox

Image Processing Toolbox

I want to be able to convert my wavelength (or frequency) data into RGB data (image), using the Image Processing Toolbox.

Best Answer

The ability to perform wavelength to RGB transformations is not available in Image Processing Toolbox.
To work around this issue in MATLAB 7.0 (R14) or later versions, you can use 2 files that were uploaded to MATLAB Central (you will still need the Image Processing Toolbox to use them):
1. spectrumRGB - Converts spectral wavelengths to RGB values.
2. colorMatchFcn - Raw data for various color matching functions.
These files can be found by searching for the keyword, "spectrumRGB," at the following URL:
An example of using these files is:
sRGB = spectrumRGB(380:780);
figure; imshow(repmat(sRGB, [10 1 1]))
Note that MathWorks does not guarantee or warrant the use or content of these submissions. Any questions, issues, or complaints should be directed to the contributing author.
There are other applications that perform this transformation. One example written in FORTRAN, can be found at:
You can manually translate this FORTRAN code into MATLAB code, or run the FORTRAN code as a MEX-file from within MATLAB.
For information on how to create Fortran MEX-Files, type the following command in MATLAB:
web([docroot '/techdoc/apiref/bqoqnz0.html#bqoqoes-1'])