How can I detect if a color is gray

I’m trying to programatically detect if a color is “gray” or not.

The best measure of “grayness” I could find was the saturation. The problem that I’m running into is that different hues look more or less gray depending on their hue and lightness.
In the picture below one looks distinctly gray and the other one red/brown even though both have the same saturation and lightness.

Is there a color space that more accurately represents “grayness” of a color?

Is there an official term for the concept of “grayness”?

two gray tones

Answer

With full credit to @Wolff for these images. As was discussed, grey is 100% relative to lighting, surrounding colors, perception, and the method you are measuring. Take these images for example. The main image actually has no “red” in it at all. If you take an eye dropper and measure any area that looks red, they are all actually shades of grey.

Not Red, Red images

if you take a snip of the parrots wing and take it out of context, it looks like browns and greys.

Parrot Wing Snip

If you put that exact same snip back over the parrot, it looks red again in context with the blue/green.

Combined

But that being said, LCH or LAB would be your best bet to measure for neutral grey.

@Luciano’s recommendation of this article: Color Theory: Is there a measurement of “colorfulness”? Has some good information for what you are trying to do.

Attribution
Source : Link , Question Author : cubefox , Answer Author : Wolff

Leave a Comment