Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell a RGB color is basically BLUE? in c#

Tags:

c#

colors

rgb

I have a set of images of the sky, some with clouds, and some without.

Some are clear blue skies, some partly cloudy, some murky with white and grey clouds.

How can I determine that a particular RGB value is, more or less, blue?

Any shade of blue is 'blue' - light blue, dark blue, navy blue, sky blue - these are all blue.

I want to reduce the colors in the image down to 16. Then I want to make a histogram of White, Silver, Grey, Blue and 'everything else'.

How do I know from the RGB value what is a blue or a silver, a white or a grey, or something else?

like image 887
Chris Avatar asked Jun 19 '11 03:06

Chris


People also ask

How do you interpret RGB values?

RGB defines the values of red (the first number), green (the second number), or blue (the third number). The number 0 signifies no representation of the color and 255 signifies the highest possible concentration of the color.

What color is R 255 G 255 B 255?

1.1 RGB circles with additive colour mixing Black: RGB(0,0,0) White: RGB(255,255,255)


1 Answers

RGB isn't the best color space to work in for this sort of thing. A color space such as HSV (also known as HSB) provides a more intuitive and descriptive model for a given color.

So, to get what you are after you can use the Hue of a given color. If you are dealing with a System.Drawing.Color structure you can use the GetHue() method which returns a hue value in degrees. Given a Hue wheel like the following you can define an upper and lower threshold (in degrees) for what Blue values you will accept.

Hue Wheel

Image processing and Color theory in general are far from trivial subjects. I would suggest that you find the simplest method that meets your requirements. This may be enough for you, or maybe not. If not then perhaps you can narrow the question down a bit for me.

Also realize that you will still need some threshold for the Brightness and Saturation components to ensure that you aren't actually dealing with black, white, or gray.

like image 121
Ed S. Avatar answered Nov 11 '22 17:11

Ed S.