How to find "quite different" RGB?

Assuming you are given a color in RGB form, is there a way to programmatically determine if it is different from another RGB.

Say, I would like to check if the colors do not differ from each other by 30%, how to do this? Or, in another way, how can I create a color that is quite different from another color?

+4
source share
4 answers

Consider the RGB value as a point and use the distance formula from the geometry.

distance = ( (R2-R1)^2 + (G2-G1)^2 + (B2-B1)^2 )^.5 distance > minimun value 

In the case of the desired 30% difference, make the minimum value = distance from point_1 * .3 from the origin, i.e., 3 ((R1) ^ 2 + (G1) ^ 2 + (B1) ^ 2) ^. 5

-1
source

This is a minefield because human optical processing is terribly dirty. but what you are asking about is the color difference - this page provides various different formulas that can be used to calculate different values ​​representing the "difference" between the two colors.

[update] and here is an online calculator that apparently calculates these differences for you (it's complicated, and the links don't change the URLs, so it's hard to link to it, but if you click it might make sense ... .)

+7
source

This is very subjective. However, I personally believe that your best chance is to use hue-saturation (HSL, or HSV, for that matter), and try to get the value out of the difference in values. For example, something like:

 value = a*abs(H1-H2)+b*abs(S1-S2)+c*abs(L1-L2); 

and try, through trial and error, to find the best constants a , b and c that distinguish colors of the same amount as your human judgment. If you know linear regression, you can have several colors of the sample with the differences you specify and get the values a , b and c with linear regression.

A more suitable formula may contain, for example, the difference in power 2 instead of abs and, more importantly, the values ​​for a , b and c as a function of the colors themselves, and not the constants.

+2
source

I think the same problem you had with flowers, a few hours ago, on a different issue. Read about HSV (or HSL) at wikipediahttp: //en.wikipedia.org/wiki/HSL_and_HSV: when converting from RGB → HSV, the value H is the color, S and V are other characteristics.

If you want to know the distance between the colors, just measure the value of H. If you convert it to a 360 degree designation, 30 degrees is enough to give you a variety of colors.

If you want to know it in RGB colors, it gets a little more complicated: the values ​​of R, G and B can lead you to a gray “color” rather than a color.

+1
source