how to process the 400 matrices to get the true color image

7 views (last 30 days)
Hi, Now I got four hundred matrices (2D) at each wavelength with spectrometer. The wavelength range is about 500-600nm. Now I want to combine these 400 matrices to get true color of my sample. Since in Matlab, true color image is get with RGB. So the wavelength should transfer to RGB, then combine the 400 matrices. Does anyone know how to realize it?
Thank you very much

Accepted Answer

Walter Roberson
Walter Roberson on 11 May 2013
MuPAD function (that has no direct MATLAB interface):
Discussion:
Windows tool, but includes some code that could be converted:
"Dan Burton"'s page referenced by some of the above:
Now, the above talk about converting one wavelength to RGB. I am not sure how one would convert multiple wavelengths together.
  2 Comments
Xiaolei
Xiaolei on 13 May 2013
Thanks. I read the information on the website of the first link. My matlab edition is R2012a, and I couldn't find the RGB::fromWavelength. Is the 2013a edition just have it?
Image Analyst
Image Analyst on 13 May 2013
It's in the Symbolic Toolbox. You don't want the RGB value of a single monochromatic wavelength. You have lots of wavelengths. So you'd have to call that function for every wavelength and add all the RGB values together.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 11 May 2013
What you have to do is to multiply each image by the spectral responsivity of the sensor at each wavelength and then sum them up. Do this for each color sensor (R, G, and B). One way to do it is to use the equations in the upper left cell of the table on the "Math" tab of Bruce Lindbloom's site: http://www.brucelindbloom.com/ But that's a perceptual way, involving the human visual system. For best results, just get the spectral responsivities from your camera manufacturer (or the camera that you want to predict took this RGB image you're trying to create), and multiply and sum over all wavelengths. So you have 3 spectral responsivities, one for red, one for green, and one for blue that you get from your camera manufacturer (or make some up).
% Initialize newRed, newGreen, newBlue with zeros() function.
% Then sum up weighted images at each wavelength.
for wavelength = 1:numberOfWavelengths
responsivityR = sr_R(wavelength); % Get weighting for red sensor.
responsivityG = sr_G(wavelength); % Get weighting for green sensor.
responsivityB = sr_B(wavelength); % Get weighting for blue sensor.
% Now weight your image at that wavelength by the weighting factors and sum
newRed = newRed + myImage(wavelength) * responsivityR;
newGreen = newGreen + myImage(wavelength) * responsivityG;
newBlue = newBlue + myImage(wavelength) * responsivityB;
end
newRGB = cat(3, newRed, newGreen, newBlue);
% Then normalize to 0-255.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!