Page 1 of 1

Animation: Auto-convert adjacent static pixels to transp.

Posted: 2013-06-17T10:53:41-07:00
by Copperfield
Hello,

I would like to ask if there is any way in ImageMagick which would help in the following case:
  • I have a sequence of images (frames from a video) as the source for an animated GIF.
  • Only a small amount of pixels change between frames - eg. most of the canvas remains unchanged between adjacent frames (for example, a small ball moving on a static field).
  • When I simply convert the images into an animated GIF, the resulting file will be roughly as large as the sum of all input files (despite only a few pixels needing to be updated).
What I would like to ask:
Is there a method in ImageMagick which would compare the adjacent image segments and automaticaly remove the pixels that did not require a change?

I've tried using the various available optimization methods (-deconstruct, -layer Optimize, etc.) but either I'm doing something wrong, or none of them were designed to handle the above mentioned case.

I can achieve what I need by doing it manualy - ergo painstalkingly removing most of those static pixels in an editor, and then using the modified images for input. This however is not really feasible when the sequence contains a larger amount of frames (like from a video).

My aim is to optimize the size of the final GIF file, where by this method it can be signifficantly reduced (up to a few orders of magnitude in speciffic cases) without a change in visual appearance (when compared to the much larger static full canvas sequence).

Hope I've managed to explain the problem clearly enough for anyone to understand :?
I would be grateful for any kind of advice on how I could achieve this without the need to edit all frames manualy in editor :(

Thanks in advance :)

Jason

Re: Animation: Auto-convert adjacent static pixels to transp

Posted: 2013-06-30T22:58:04-07:00
by anthony
YEs.

-layers 'OptimizeTransparency'

This replaces any pixel that does not change from one frame to the next with transparency. You can also specify a 'fuzz' factor to also make baraly changed colors transparent too.

See IM Examples, Animation Optimizations, Transparency Optimization
http://www.imagemagick.org/Usage/anim_opt/#opt_trans

related to this is LWZ compression optimization which follows on from transparency optimization.