Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the wavelength of a pixel using RGB?

Tags:

I have a project that would classify the color of a pixel. Whether it is red,violet, orange or simply any color in the color wheel. I know that there are over 16 million color combination for pixels. But I was able to read a web page that says its possible for me to do my project using the wavelengths of color. Please give me the formula to compute for the wavelength using RGB values. Thanks!

like image 736
Amiel Avatar asked Apr 28 '11 10:04

Amiel


People also ask

What is the wavelength of RGB?

red, green, and blue (638 nm, 520 nm, 450 nm) laser wavelengths.

How do you find RGB pixel value?

Get the pixel value at every point using the getRGB() method. Instantiate the Color object by passing the pixel value as a parameter. Get the Red, Green, Blue values using the getRed(), getGreen() and getBlue() methods respectively.

What is pixel range of RGB?

In RGB, a color is defined as a mixture of pure red, green, and blue lights of various strengths. Each of the red, green and blue light levels is encoded as a number in the range 0.. 255, with 0 meaning zero light and 255 meaning maximum light.


2 Answers

A pure color has a wavelength (any single color LED will have a specific wavelength). Red, green and blue each have a range of wavelength. However, when you make an RGB color, you add these wavelengths together, which will NOT give you a new wavelength. The eye can't distinguish a yellow composed of one wavelength from that of adding red and green (just how the eye works). I'd recommend reading up on color theory

http://en.wikipedia.org/wiki/RGB_color_model

like image 63
Matthias Wandel Avatar answered Sep 21 '22 08:09

Matthias Wandel


Well RGB for a monitor maps to 3 independant levels of Red Green and Blue light, so there are (mostly) 3 distinct wavelengths present of any one percieved colour.

BUT If you can convert your RGB colour value to its equivilent HSL, the H part (Hue) is the dominant colour in so far as wavelength goes if you are prepared to ignore the saturation (think of it as whiteness).

Based on that you could approximate the dominante wavelength of a colour based on its H value.

Red light is roughly 630–740nm wavelength, Violet is roughly 380–450nm.

like image 32
Pete Stensønes Avatar answered Sep 20 '22 08:09

Pete Stensønes