How can I say that the color RGB is mostly BLUE? in c #

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

Some of them are clear blue skies, some are cloudy, some are cloudy with white and gray clouds.

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

Any blue shade of blue - cyan, blue, blue, cyan - they are all blue.

I want to reduce the color of the image to 16. Then I want to make a histogram of white, silver, gray, blue and "everything else."

How to find out from the value of RGB what blue or silver, white or gray, or something else?

+6
source share
3 answers

RGB is not the best color space to work with. 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 need, you can use a hue of a given color. If you are dealing with the System.Drawing.Color structure, you can use the GetHue () method, which returns the hue value in degrees. Given the Hue wheel, as shown below, you can define the upper and lower threshold (in degrees) for the Blue values โ€‹โ€‹that you accept.

Hue wheel

Image processing and color theory are generally far from trivial objects. I would suggest that you find the simplest method that fits your requirements. This may or may not be enough for you. If not, then maybe you can narrow the question down a bit for me.

Also make sure that you still need some threshold for the luminance and saturation components to make sure that you are not actually dealing with black, white, or gray.

+13
source

If the values โ€‹โ€‹of red and green are close to one, and if the blue value is greater than red and green, the color will be in the blue range. If all three values โ€‹โ€‹are about the same, you have some version of gray, and if they are close to their maximum, the color will look white. Itโ€™s impossible to be more accurate than this - you just need to look at the color picker and find out which region looks โ€œblueโ€ for you.

+2
source

Perhaps create a table with RGB values โ€‹โ€‹for each of the 16 colors you want, then compare each RGB value of each pixel with each of the values โ€‹โ€‹in the table. For comparison, make a substring such as R1-R2 G1-G2 B1-B2, then sum the differences and convert it to a color that is different from the other.

Related question: Compare RGB colors in C #

0
source

Source: https://habr.com/ru/post/890845/


All Articles