Visually compare two images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Visually compare two images

Post by lorents »

Good evening! tell me how to use ImageMagick, you can visually compare two images and give a ratio difference images?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Visually compare two images

Post by fmw42 »

lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Visually compare two images

Post by lorents »

Thank you for your reply.I can't understand how you can obtain the coefficient of difference images?
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Visually compare two images

Post by lorents »

Tell me which option to use -metric type for the evaluation of visual changes image?
Last edited by lorents on 2015-05-31T22:37:53-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Visually compare two images

Post by fmw42 »

The compare looks at various accumulative metrics from the pixel by pixel color difference (channel by channel) such as the absolute error, peak absolute error, mean absolute error, root mean squared error, etc. See http://www.imagemagick.org/Usage/compare/#statistics. Use Google or Wikipedia to look up the equations that are used to compute those metrics. Choose what you feel gives you the best measure of difference. I almost always use root mean squared error.

If the two images are the exact same size:

Code: Select all

compare -metric rmse image1 image2 differenceimage
The output will be an visual image and a set of numbers to the terminal. The numbers tell you how good a fix. For most metrics (such as the rmse), the smaller the number the better the match between the two images.
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Visually compare two images

Post by lorents »

Read an article about SSIM, which is not in ImageMagic? they say it is better to use it to compare images. Tell me, is this so?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Visually compare two images

Post by fmw42 »

I have no idea if it is better. There are many steps in that reference process, which would have to be done as preprocessing. The final step is a Minkowski error metric, which would not be hard to add to compare, but would require a define or new argument for exponent. The rmse metric is a Minkowski error metric with the exponent set to 2.
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Visually compare two images

Post by lorents »

Thank you very much!
Post Reply