How do you compare the similarity between two color images?

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

I want to compare how close the two images are (red in a similar area), but I cannot go pixel by pixel because their color arrangement is not exactly the same. Does anyone know what would be a good approach here?

Thank,

+3


source to share


1 answer


I personally recommend using the indico image API. Basically, you pass in an image you are dealing with and return a set of functions that represent higher-level morphological structures in that image.

If you compute cosine similarity on top of these functions, you will get a more intuitive similarity metric.

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

The code itself is pretty simple:



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

      

Full docs here

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

+2


source







All Articles