Page 1 of 1

### Calculating and comparing an absolute error metric for images

Posted: 2015-03-27T21:33:44-07:00
So I'm using compare to compare two images using the AE metric:

Code: Select all

``compare -metric AE -fuzz 15% image1.png image2.png /dev/null``
What I don't know how to do now is to output a comparable "value" for each image. Currently, I am iterating through many combinations of the same image and running compare on each combination, which is taking a long time.

1. Can I first run through every image individually and get ImageMagick to output some sort of value/hash/whatever that I can save?
2. Can I then run through all the permutations of the images I have and simply use the output from 1 to more quickly compute a similarity percentage?

I was previously using pHash to output a hash for every image then used a script to compare all these hashes, which was super fast. However, I don't know how to do something similar using ImageMagick's absolute error comparison metric.

### Re: Calculating and comparing an absolute error metric for images

Posted: 2015-03-28T03:53:58-07:00
LucasTizma wrote:I was previously using pHash to output a hash for every image then used a script to compare all these hashes, which was super fast. However, I don't know how to do something similar using ImageMagick's absolute error comparison metric.
All comparison metrics compare two images with each other. They don't (and can't) create a value for a single image.

### Re: Calculating and comparing an absolute error metric for images

Posted: 2015-03-28T11:39:32-07:00
pHash does create a unique, comparable hash just based on the image alone, not a comparison. These hashes can be compared quickly. I wasn't sure if other metrics could do the same. But I suppose not.

### Re: Calculating and comparing an absolute error metric for images

Posted: 2015-03-28T12:21:43-07:00
IM has a phash. See viewtopic.php?f=4&t=24906. Also

identify -moments -verbose zelda3.jpg

will display the 7 pairs of phash values

or

convert zelda3.jpg -moments -verbose info: > moments.json

will write them to a json file.

If you are on Linux, Mac OS or Windows with Cygwin, I have two scripts that convert the phash values into one string of digits and another script that will compare two strings of numbers via a rmse metric. See my link below and phashconvert and phashcompare. You cannot compare them using the hamming distance, though. The phash is for color images, not grayscale.