10

I want to compare a source png file to a compressed file.

I am using imagemagick and this command:

convert image1 image2 -compose Difference -composite \
       -colorspace gray -format '%[fx:mean*100]' info:

But what I get is a very odd number. I am looking from a number from 0-100%.

When I compared two totally different images I still get a 8.37885.

So good people of Ask Ubuntu, can you provide me with a command that will measure the difference between files properly and give me a number from 0-100?

11

The problem is with the colorspace gray part of the command. This option checks only difference between gray colour of the images.

So the correct command should be

convert image1 image2 -compose Difference -composite  -format '%[fx:mean*100]' info:

This should give you more appropriate answer.

  • 1
    You could try other methods like this python script. Use that method which best suits your purpose. – Registered User Jun 30 '14 at 13:21
  • Thank you very much for your help I will look into it, thank you for the command as well – Levan Jun 30 '14 at 13:26
  • @RegisteredUser Warning: that code seems to find the RMS error between the images’ histograms, NOT between the images themselves. It's better to do first the difference of the 2 images (if you want in a new image too), and then to do the squared sum of the normalized histogram bins. – Hastur Feb 12 '15 at 10:28
  • @hastur can you please elaborate by providing the command. Maybe as another answer. – Registered User Feb 16 '15 at 4:57

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.