Q:

Computing Image Similarity based on Color Distribution

Image Similarity based on Color Palette Distribution
I am trying to compute similarity between two images based on their color palette distribution, let's say I have two sets of key value pairs as follows,
Img1: {'Brown': 14, 'White': 13, 'Black': 40, 'Gray': 31}
Img2: {'Pink': 82, 'Brown': 8, 'White': 7}
Where the numbers denote the % of that color present in the image. What would be the best way to compute similarity on a scale of 0-100 between the two images?

A:

Try using Earth Mover's Distance. It measures how much it "costs" to optimally reshape one histogram into another, where an elementary transform (using the terminology of edit distance-like distance measures) is moving a unit of mass from a bin to a bin. If you have an implementation of EMD, then your distance is dist = EMD(H1, H2, D), where
 H1 = [ 14, 13, 40, 31 ]; -- histogram #1 (first image)
 H2 = [ 82, 8, 7 ]; -- histogram #2 (second image)
 D  = [ D11, D12, D13; ... ; D41, D42, D43 ]; -- (cross-bin) ground distance

Dij is a distance from the i'th bin of the first histogram to the j'th bin of the second histogram. For example, D21 is a distance between 'White' and 'Pink'. It may be defined differently, based on which color space you want to use, and further, based on how you define what it means for two colors to be similar. If I use RGB, and I do not care much as to how human eye perceives colors, then D21 can be the \ell_2 norm of the difference [1, 1, 1] - [1, 0.05, 0.7]. (As far as I remember, the paper I mentioned uses LAB instead of RGB.)
P.S. Besides color, you may include spatial information into comparison. EMD can handle it well, as long as you properly combine similarity of colors with spatial similarity in the definition of ground distance D.

