Expressing RGB color Hue as Green-pivoted ratio of Red and Blue components?

94 Views Asked by At

I am coding software where I want to compare color hues by ratios of Red and Blue to Green, avoiding the usual Hue calculation in the HSV/HSL color models, because that calculation involves tests for predominant color.

For example, in an orangey color, Red may be 80 greater than Green, Blue may be 70 lower, so the ratio would be 80/-70 or -1.14. If I then have another, fainter orangey color, the ratio may be 40/-35, giving the same result of -1.14. Nice and simple, easy to work with.

The problem is that a cyanish color with the ratio of -40/35 will have the same result. In addition, ratios with a 0 won't work, such as red 255/0.

I'm running around in circles, trying various approaches, with no solution in sight. Is there a way of making this work?

1

There are 1 best solutions below

0
On

It can't be done. As I worked toward a solution, it became clear that the solution I was working toward was the Hue calculation in the HSV/HSL models. The reason is that the Hue is circular (whether expressed as 0.0-1.0 or 0-360), and that means that the ratios must be found for each predominant color. Anchoring the ratios on one color only, offers no way of completing the cycle.