I have to calculate the difference of two images. Currently I do this with imagemagick. The following code works well for jpg or single page tiffs:
convert fileA.jpg fileB.jpg -compose -Difference -composite -colorspace gray -format '%[fx:mean]' info:
When I edit a multipage tiff on the second page and use command above with modified and unmodified tiff, I get the same result like compare fileA with itself, so I think that imagemagick compares page 1 with page 2 of fileA.
Actual I split the multipage images into single image files and compare page by page, but this is slow!
Windows:
...>magick -version
Version: ImageMagick 7.0.8-11 Q16 x64 2018-08-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
Ubuntu 14.04
....# convert -version
Version: ImageMagick 6.7.7-10 2018-07-10 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
How can I get a percentage difference of the two compared tiffs fast? Maybe there is a way with imagemagick or another with bash/java/...
You should be able to do that by appending all the pages of each TIFF image together before doing the composite in Imagemagick. For example with a 4 page test tiff that I made, where the second page has been blurred:
convert \( test1.tif +adjoin -append \) \( test2.tif +adjoin -append \) -compose difference -composite -colorspace gray -format '%[fx:mean]\n' info:
0.00847632
You can also do that with -layers composite and get the difference for each page.
convert test1.tif +adjoin null: test2.tif +adjoin -compose difference -layers composite -colorspace gray -format '%[fx:mean]\n' info:
0
0.0324311
0
0