I've been lately thinking on going to the roots of image processing by studying more about the colors.

What properties can be defined for a color?, how do we represent them?, can we compare two colors?, can we find similar colors?... in fact, what do we mean by similar colors?

Colors are usually compared depending on the context: colors for graphic design, colors for textile applications, colors similar to human perception,...

Depending on the context, there are different algorithms to compare two colors and give a numeric value to the "distance" between them. Unfortunately, we are not comparing two single points on a plane where a basic euclidean distance would be enough.
We need to take care to understand that colors are not easily represented on a plane so the distance between two colors is not a very simple easy concept. I.e. what's more similar to green: yellow or orange?

We tend to think on colors as a flat plane where colors have a fixed "area" assigned or a 3D cube for web developers as they are used to work on the RGB model.

The RGB model allows us to represent the color values depending on 3 axis which makes very easy to create a 3D cube of available colors:

Let's keep our previous example and convert them to RGB:

  • green: #00FF00
  • yellow: #FFFF00
  • orange: #FFA500

We could play around with the values in RGB, interpret them as vectors in a 3D plane and calculate the angle formed between the pairs green-yellow and green-orange in order to calculate the "closest" color but again is this space model allowing us to find similarities in colors?... the answer is NO.

Color perception goes beyond the vectors calculation as the human eye is manipulating the colors because it's more sensitive to some colors than others.

After searching a lot about this subject, I found out that applications that need to compare colors are often converting them to (CIE) LAB format which is a representation closer to the human eye perception of the colors.

Once we have the numbers in the LAB model, we can use one of the multiple suggested matching algorithms available depending on where are we going to use the colors.

I decided to use multiple different algorithms on a demo in order to compare them and see how good/bad are in comparison with my eye perception.
As I was working on the mosaic demo, I decided that it would be a really great application of this theory so different color matching algorithms would be compared by generating the best mosaic.

The next algorithms were implemented to compare:

Article references:

No comments :