Way to do a batch-comparison/revision

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
Sterling7
Posts: 2
Joined: 2012-08-11T22:31:27-07:00
Authentication code: 67789

Way to do a batch-comparison/revision

Post by Sterling7 »

Hello. New to the forum here, thanks for any help you can give; much searching seems to suggest the ImageMagick might be able to do what I need, and I'm certainly hoping this is the case!

I'm working with creating animation- a series of frame files, in .jpg or .png format. What I need to be able to do, ideally, is have the program look at two *nearly* identical frames, and create a new image file that consists of only the differences between one and the other- in other words, create "image 3" which is "image 2" minus any similarities "image 2" might have had with "image 1", if that makes sense.

I'm looking to be able to, for example, have a series of frames where a knight swings his sword, with one series where the knight has a particular crest on his shield and another where he has a different one, and just have the crest (while still having that crest in the image move appropriately with the shield.) And if there was a way to do it with batch processing (since some of these animations may have 120 images or more!) that would be ideal.

Thanks again for any suggestions.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Way to do a batch-comparison/revision

Post by fmw42 »

You do not say what platform you are using. Scripting is different in windows from unix.

Any way, the command find the difference between two images is.

convert image1 image2 -compose difference -composite result

or you could use

convert image1 image2 -compose minuse -composite result

You could also use compare to get the difference highlighted.

compare -metric rmse image1 image2 differenceimage


See

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

Which one you use depends upon your what you need to find.

To compare multiple images, you need to loop over all your images in pairs and do whatever of the above command you want. The looping is done outside IM in a windows .bat or unix shell scripts
Sterling7
Posts: 2
Joined: 2012-08-11T22:31:27-07:00
Authentication code: 67789

Re: Way to do a batch-comparison/revision

Post by Sterling7 »

Sorry about the omission. I'm using Windows Vista 64, and the dynamic x64 build.

Thanks for the suggestions!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Way to do a batch-comparison/revision

Post by fmw42 »

Sterling7 wrote:Sorry about the omission. I'm using Windows Vista 64, and the dynamic x64 build.

Thanks for the suggestions!
What version of IM?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Way to do a batch-comparison/revision

Post by anthony »

Sterling7 wrote:I'm working with creating animation- a series of frame files, in .jpg or .png format. What I need to be able to do, ideally, is have the program look at two *nearly* identical frames, and create a new image file that consists of only the differences between one and the other- in other words, create "image 3" which is "image 2" minus any similarities "image 2" might have had with "image 1", if that makes sense.
I did this once before... My solution to generating a 'difference animation' was to append all the frames, create thge difference then separate them again...

See Comparing Animation (where I joted down the command I used)
http://www.imagemagick.org/Usage/compare/#animation

There is alternatives using -compose difference with -layers composition, and I have used it to merge a series of photos at versious focal depths, though not for animations. It would however be perfect for animations without needing the 'append' trick.

Layers Composition - alpha composition for image lists
http://www.imagemagick.org/Usage/anim_mods/#composite
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply