compare -metric

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
dos

compare -metric

Post by dos »

hi all, i was using the "compare -metric rmse x.png y.png null:". the results i got are "4632.57 (0.0706886)".
more verbose results:

Code: Select all

x.png PNG 970x865 970x865+0+0 8-bit DirectClass 68.9KB 0.016u 0:00.014
y.png PNG 970x865 970x865+0+0 8-bit DirectClass 173KB 0.031u 0:00.031
Image: x.png
  Channel distortion: RMSE
    red: 3739.74 (0.0570648)
    green: 4016.91 (0.0612941)
    blue: 5853.29 (0.0893155)
    all: 4632.57 (0.0706886)
x.png=> PNG 970x865 970x865+0+0 8-bit DirectClass 0.188u 0:00.062
Can anyone explain in detail the results I got? Can you also tell what are max. and min. values for output? If you could refer me to documentation which explains the outputs for rmse in detail... thanks in advance!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: compare -metric

Post by fmw42 »

4632.57 (0.0706886)
The first number is the rmse value pixel values in the range 0 to QuantumRange which looks like Q16 IM or 655535. The second number is normalized to the range 0 to 1. So in this case in percent it would be 7% rmse error.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: compare -metric

Post by anthony »

RMSE => Square Root Mean Squared Error.

It means for each pixel get the color differance, and square it, average all the squared differences, then return the square root of that.

Other metrics include...
MAE -- Mean Absolute error - or just the average of all teh color differences
MSE -- Mean Squares Error

As such RMSE = sqrt(MSE)

For maximum color difference use
PAE -- Peak Absolute Error
PSNR -- Peak Signal Noise Ratio, which is a logarithmic 'decibel' scale.

And you also have
AE Just a count of pixels that differ by more than -fuzz amount (default to zero meaning ANY DIFFERENCE).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lizac
Posts: 15
Joined: 2011-03-25T19:39:37-07:00
Authentication code: 6789
Location: Philippines

Re: compare -metric

Post by lizac »

Hi! Do you know how can I retrieve those values from the first post?
Ex. I want to use the 3739.74 and test it if it's equal to Zero or not in Vbcrispt? If it's zero then the image has no difference.

I'm using Bat actually. Not sure if this is correct.
FOR /F "tokens=*" %%G IN ('compare -metric AE first.png second.png null:') DO SET _value=%%G

and the comparison will take place in vbscript. I actually don't know how to convert this vbcsript. Any help from you will be very much appreciated. Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: compare -metric

Post by fmw42 »

the values are written or accessible from standard error (in unix 2>&1)

val=$(compare .... 2>&1)

sorry I don't know the windows equivalent
lizac
Posts: 15
Joined: 2011-03-25T19:39:37-07:00
Authentication code: 6789
Location: Philippines

Re: compare -metric

Post by lizac »

Hi! fmw42.

Thanks again for your response and to my other post. You are so kind.

Anyways, I just hope that anyone who knows windows scripting would be able to jump in and share their knowledge.
My dilemma is this is a time-constraint project and studying from top gives me a lot of time pressure.

Thank you so much again!
lizac
Posts: 15
Joined: 2011-03-25T19:39:37-07:00
Authentication code: 6789
Location: Philippines

Re: compare -metric

Post by lizac »

Hi! This has answered my inquiry. If anyone would be interested to know.

http://studio.imagemagick.org/discourse ... 982#p68260
Post Reply