2

I'm implementing a Python script to check the similarity between two images. I've been forced to use Imagemagick, so I've chosen to use Wand as Python library. My work flow is something like this:

from wand.image import Image

img1 = Image(filename='/path/to/first/image')
img2 = Image(filename='/path/to/second/image')

# Normalize the two images in order to avoid exposition-related issues
img1.normalize()
img2.normalize()

# Create a 64 x 64 thumbnail for every image
img1.resize(64, 64)
img2.resize(64, 64)

# Compare the two images using root mean square metric
comparison = img1.compare(img1, metric='root_mean_square')[1]

Usually this method (root_mean_square) gives me a value of 0.0 for extremely similar images, >= 0.1 for images that are similar and >= 0.5 for images that aren't similar. My question is: is this a good way to compare two images using this tools? There is a better way? There is a better metric?

g_rmz
  • 721
  • 2
  • 8
  • 20

0 Answers0