compare images with tolerance

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?".

compare images with tolerance

Postby kidman » 2013-08-19T03:31:11+00:00

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.
kidman
 
Posts: 1
Joined: 2013-08-19T03:20:06+00:00

Re: compare images with tolerance

Postby Bonzo » 2013-08-19T04:31:58+00:00

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?
Bonzo
 
Posts: 2223
Joined: 2006-05-20T08:08:19+00:00
Location: Cambridge, England

Re: compare images with tolerance

Postby GreenKoopa » 2013-08-19T07:33:21+00:00

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?
User avatar
GreenKoopa
 
Posts: 452
Joined: 2010-11-04T17:24:08+00:00

Re: compare images with tolerance

Postby fmw42 » 2013-08-19T10:11:51+00:00

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
User avatar
fmw42
 
Posts: 15008
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA


Return to Users

Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 22 guests