Page 1 of 1

compare images with tolerance

Posted: 2013-08-19T03:31:11-07:00
by kidman
Hi,

I want to compare images but with a user specified tolerance (ex. 20% diff is accepted). So what I have in mind is:

compare -verbose metric AE REF_IMAGE OUTPUT_IMAGE DIFF_IMAGE
The output looks like this:
OUTPUT_IMAGE PNG 598x484 598x484+0+0 8-bit DirectClass 25.5kb
REF_IMAGE PNG 598x484 598x484+0+0 8-bit DirectClass 25.5kb
Image:
Channel distortion: AE
red: 600
green: 600
blue: 600
all: 600

So the total image size in pixels is 598*484 and the number of diff pixels is 600 (extracted from "all"). And then dividing the diff by the total number pixels multiplied by 100 gives me the percentage of different region of the image. Is this a correct? Does "compare" offer this or better method?

Thanks.

Re: compare images with tolerance

Posted: 2013-08-19T04:31:58-07:00
by Bonzo
Have you checked the Usage site?

I wonder if you can use a -fuzz 20% and get an output if the image is over under the 20% difference?

Re: compare images with tolerance

Posted: 2013-08-19T07:33:21-07:00
by GreenKoopa
Welcome. Also see
http://imagemagick.org/script/compare.php

Is AE the metric you want? Are only regions of your image changing? Is the image format lossless? Is a slightly brightened image 100% different?
AE = absolute error count, number of different pixels (-fuzz effected)

Or do you have your method working, and you only need pointers on formatting the output?

Re: compare images with tolerance

Posted: 2013-08-19T10:11:51-07:00
by fmw42
Do your compare (I recommend using -metric rmse, but that is my preference) and then threshold the output to give you your 20% tolerance. You could also use -compose difference and the threshold the output. see

http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
http://www.imagemagick.org/Usage/compare/#statistics
http://www.imagemagick.org/Usage/compose/#difference