0

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?

Theo d'Or
  • 173
  • In your example of $-1.14$, the same ratio will give four different colours (the first number can be positive or negative, and the second number also can have two different signs). If you then compare red and green to blue, you might be able to avoid this problem. In case of division by $0$, you can simply let the ratio differ by a small amount such as $(255-1)/(0+1)$. – Toby Mak Jun 05 '20 at 12:15

1 Answers1

1

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.

Theo d'Or
  • 173