3
$\begingroup$

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?

$\endgroup$
3

4 Answers 4

2
$\begingroup$

Ya, pretty much agree with everyone here. The first thing you're going to want to do is transform to a perceptually uniform color space; for me, either HSL or LAB have worked the best, depending on the application.

From there, creating a color histogram for each image and comparing the histograms is probably the best way to go. Here's an interesting post on different methods for doing this: http://www.pyimagesearch.com/2014/07/14/3-ways-compare-histograms-using-opencv-python/

$\endgroup$
0
$\begingroup$

You're probably best off treating the color palettes as ordinary numerical vectors and using any one of the popular distance metrics for vector spaces, i.e. euclidean distance, cosine distance or mahalanobis distance.

The only reason I wouldn't do this is if there is some way you want to incorporate the similarity of non-identical colors in your comparison. For example should the distance between {'Pink' : 100} and {'Purple' : 100} be different than the distance between {'Black' : 100} and {'White' : 100}. If so, then you might want to look at different color spaces for representing your vectors but it depends on what you're trying to achieve.

$\endgroup$
0
$\begingroup$

The problem's a bit more complicated than you think. If you want to compute the perceived similarity when viewed, you're going to have to aren't going to be able to just work with pixel values as they are contained in an image file. The first thing you'll have to do is a gamma adjustment (http://www.poynton.com/GammaFAQ.html), and although I'm a bit rusty on this stuff, I think you'll need to then convert to a perceptually uniform color space.

Hopefully someone on this forum will know more.

$\endgroup$
0
$\begingroup$

Thanks a lot for the insights, I have decided to start with weighted Jaccard similarity first as defined below.

Weighted Jaccard Similarity

Then maybe I will look into some histogram comparing approaches as described here, https://stackoverflow.com/questions/6499491/comparing-two-histograms

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.