I understand there's a challenge in the conversion as the colors are not monochromatic and there could be metamerism. I just want an approximation for the purpose of visualization of data.
As in I have extracted a set of RGB values from an image i.e. a 256*3 matrix. Assuming each combination of RGB gives different colors, can I can get a distribution of the colors in the image (x axis having visible wavelength range) and thereby a distribution of the wavelengths (dominant for ease and approximation) corresponding to each color?
No not the histogram. I want the distribution of all the colors and the number of pixels in each color (arising out of every RGB combination) without grouping them into Red Green and Blue.
I'm trying to get the image below from the RGB matrix:
In this case you have (2^n)^3 different colors; If n = 8 (the data class is uint8) , then you have 16,777,216. This number is the total range including all possible colors in this case. Now it is easy, each RGB pixel should be assigned to its own value according to its components. you can do it manually using MATLAB.
Aparna Sathya Murthy I converted them too HSV and got the hues but converting them to wavelengths did not yield expected values. Can you please elaborate more?
What I was thinking was , take the RGB values and combine then to one value like - R*82 + G*81 + B*80 now you have a "color" this needs to be compared with the CIE color space , this explains better