Page 1 of 1

Difference image not working

Posted: 2015-06-05T15:46:39-07:00
by ChrisPugh
Hi,
First time user. I am trying to create a difference image and for some reason it is not working.

I was able to get a difference mask using compare, to identify which images have diffs, but this is useless for my purposes.

I need the actual difference magnitudes.

All the resources online I found say I should be able to do this with:
composite base/$file opt/$file -compose difference out_$file

but the result is completely incorrect.

I even run this script, to composite the original image and itself and I get parts of the image black, parts of the image the original color, and parts of the image random garbage. The difference of an image with itself should be a completely black image so can someone please help me figure out what the correct script to do what I want is?

Version : ImageMagick 6.9.0-0 Q16

Thanks!

Re: Difference image not working

Posted: 2015-06-05T17:30:04-07:00
by fmw42
try

Code: Select all

composite -compose difference base/$file opt/$file out_$file
or better use the more modern convert

Code: Select all

convert base/$file opt/$file -compose difference -composite out_$file
see http://www.imagemagick.org/Usage/compose/#compose

Note that -compose difference is the absolute value of the difference. If you want use -compose minus, but that will clip out negative values unless you use HDRI compiled IM.

What kind of image files are you using? What platform?

This simple test works for me using the internal IM image rose:. The result is pure black

Code: Select all

convert rose: rose: -compose difference -composite result.png
If you cannot reproduce this, then upgrade to the current IM, 6.9.1.4, which is what I tested on my Mac OSX Snow Leopard