G
G
gleb_kudr2012-06-07 13:02:45
Algorithms
gleb_kudr, 2012-06-07 13:02:45

How to determine if two or more colors are similar?

There are several colors. Let's say 1 purple, 2 pink, 3 red, 4 blue. Their values ​​are set in RGB format
. There is a base color, for example, burgundy.

The task is to arrange the colors in descending order of their similarity to the base. Similarities from the point of view of a normal person (not colorblind).

For example, for burgundy it is red>pink>purple>blue.

And by what algorithm does this person do it? It is necessary to simulate such an algorithm on a computer. It is clear that there are different people and the algorithm may differ in weighting factors. But how to do it in general?
Can you post links to read about this?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
anmipo, 2012-06-07
@gleb_kudr

Color difference formula , also color difference formula , color difference , or color distance (distance between colors) is a mathematical representation that allows you to numerically express the difference between two colors in colorimetry.

C
Chii, 2012-06-07
@Chii

IMHO: this is a combination of the position of the color in the rainbow, brightness and saturation

T
TheMengzor, 2012-06-07
@TheMengzor

RBG > HSL and sort by all three keys: hue, saturation and lightness

X
xmoonlight, 2016-02-10
@xmoonlight

Distance on 3 channels: R, G, B (transparency - optional)
_base - these are the channels of the base (reference, reference) color, against which we check.
R, G, B - channels of the checked color:

R=abs(Rbase-R)
G=abs(Gbase-G)
B=abs(Bbase-B)
D=(sqrt(R^2+G^2)+sqrt(G^2+B^2)+sqrt(B^2+R^2))/3

where D is the distance of the checked color from the base one.
We sort D in the right order for each color and get the similarity depending on the sort.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question