Algorithm for calculating distance/similarity between sets(!) of colors

99 Views Asked by At

I would like to compare two images based on a color distribution. I've implemented an algorithm (based on kNN) that extracts 3 most dominant colors from an image, together with weights for each color. For example an output of the algorithm would look like:

[(0x00fd8e, 0.1), (0x3ff42e, 0.4),(0x48b2ef, 0.5)]

This is a set. There are three colors, each with it's own weight, which is actually a percentage [0-1] of how much it appears in an image.

What is the best way to calculate a distance/similarity between two of such sets, while taking both colors and weights into account?

I tried to convert the colors into a histogram, and do a chi-square and Bhattacharyya distance. I also tried to convert a (color,weight) into a vector by multiplying the r/g/b or h/s/v intensities with weights, normalizing them, then adding all three vectors in a set together to get one vector for each set and then comparing those vectors with Euclidean distance.

But non of these thing really worked as they should. When I compared an image with say 100 others and ranked them by similarity, they didn't appear to rank well.

0

There are 0 best solutions below