Page 1 of 1

Way to do a batch-comparison/revision

Posted: 2012-08-11T22:39:50-07:00
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.

Re: Way to do a batch-comparison/revision

Posted: 2012-08-12T11:44:03-07:00
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

Re: Way to do a batch-comparison/revision

Posted: 2012-08-12T12:58:43-07:00
by Sterling7
Sorry about the omission. I'm using Windows Vista 64, and the dynamic x64 build.

Thanks for the suggestions!

Re: Way to do a batch-comparison/revision

Posted: 2012-08-12T15:08:14-07:00
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?

Re: Way to do a batch-comparison/revision

Posted: 2012-08-22T18:41:55-07:00
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