Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to compare similarity between two color images?

two image side by side (please ignore the red line in between

I want to compare how close these two images are (red in similar area), but I can't go pixel by pixel because their color locations are not exactly the same. Anyone know what would be a good approach here?

Thanks,

like image 660
Kexin Xu Avatar asked Jun 26 '15 20:06

Kexin Xu


1 Answers

I personally would advise using the indico image features API. Basically you pass in the image you're dealing with and get back a set of features that represent higher-level morphological-structures within that image.

If you compute cosine-similarity on top of those features you'll get a more intuitive similarity metric.

There's a great github link showing how to do exactly this with a front-end slapped on if that's what you're looking for here: https://github.com/IndicoDataSolutions/imagesimilarity

The code itself is pretty straightforward though:

from indicoio import image_features
from scipy import spatial

features_1 = image_features(<path_to_image>, <api_key>)
features_2 = image_features(<path_to_image>, <api_key>)
similarity = 1 - spatial.distance.cosine(dataSetI, dataSetII)  # This is what you want

The full docs are here

Full disclosure: I am the CEO of indico, so I'm biased, but I really do think it would help in this case.

like image 66
Slater Victoroff Avatar answered Nov 13 '22 15:11

Slater Victoroff