How to display RGB values of a pixel on a spectrum

19 views (last 30 days)
I've seen similar questions, and as I understand it is not an easy and precise thing to do. But most of the questions were old.
I have a normal rgb image and I am able to choose pixels from the image. As result I get the values of RGB of those pixel. However, I want to display those values as wavelength on the spectrum. X axis should have the wavelength, Y axis should show the intensity. Additionally, I would like to see the reflectance curve of each pixel. The problem as I understood, I don't have the wavelength information. How is it possible to obtain wavelength from the RGB values. My Prof. insists that it is a very easy process but I don't think so. However, I see such graphs on the research papers where they illustrate the values of RGB as wave, also reflectance curves. How do they obtain those data and illustrate them. I can't understand, please, explain to me. Thank you in advance.

Answers (1)

Akash
Akash on 30 Aug 2023
Hi User79,
I understand that you have a normal RGB image and would like to display the RGB values as wavelengths on a spectrum, along with the reflectance curves of each pixel.
I want to clarify that converting RGB values directly to wavelengths is not a straightforward process. This is because some RGB colors do not correspond to a single wavelength, but rather a combination of different wavelengths. However, I can provide some insights and resources that might help you achieve an approximation of the desired result.
There have been discussions on this topic in the MATLAB Central community. You can find some relevant discussions in the following links:
While direct conversion may not be possible, one approach you can consider is computing the frequency for each pixel based on the RGB values and then calculating the corresponding wavelengths using the frequency-wavelength relationship. The links provided below can give you some ideas on how to iterate through image histogram data and compute pixel frequencies individually:
Additionally, you can explore the "Lambda - Wavelength Calculator" available on the MATLAB File Exchange, which might provide further assistance in your task:

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!