Spectrum graph from an image

조회 수: 15 (최근 30일)
Francesco Panico
Francesco Panico 2018년 5월 7일
댓글: Ameer Hamza 2018년 5월 8일
I'd like to plot a graph (wavelength - intensity) from an image of color like this, how I can do?
Every color should correspond to a specific wavelength of the visible spectrum and to and intensity (from black to pure color). To make the problem easier I can use also only one row of pixels.
Can you help we with this problem? Thanks

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 7일
You will need spectrumRGB() function available in this package: https://www.mathworks.com/matlabcentral/fileexchange/7021-spectral-and-xyz-color-functions?focused=5172034&tab=function to convert wavelength to RGB values. Download it and place it in MATLAB path, then run the following code
rgbValues = spectrumRGB(400:0.2:650); % go from 400 to 650 nm wavelength
image = repmat(rgbValues, 200, 1, 1); % 200 is the height of image in pixel
imshow(image)
  댓글 수: 2
Francesco Panico
Francesco Panico 2018년 5월 7일
Thanks Ameer Hamza it's a very usefull tool. How I can do the opposit process ? From the image to the wavelength ?
Ameer Hamza
Ameer Hamza 2018년 5월 8일
The answer to this question is not quite simple. The inverse mapping is not one to one. Several colours in nature are combination ( interference) of several wavelengths. For most rgb values, the result will not be a single wavelength, but a range of wavelength. Refer to this link for more details: https://www.mathworks.com/matlabcentral/answers/240430-rgb-to-wavelength-is-it-possible#comment_308370

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 5월 7일
There are lots of ways to make a color, not just one. Have you ever heard of metamerism? Why don't we make an assumption that your spectrum is just monochromatic spikes (like lasers). Then you can simply say that the left color is 400 nm and the right color is 700 nm, and simply make up a lookup table giving the wavelength for some input RGB value.

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by