Page 1 of 1

Less lossy animated image sequence?

Posted: 2009-04-26T16:39:23-07:00
by daviddoria
I used

Code: Select all

convert -delay 60 -loop 0 Complete_?.png animated.gif
to convert a sequence of png's into an animated gif. I noticed the quality in large patches is not that great. After reading about gif in the imagemagick docs it seems like there is a very small color range, which is likely causing this information loss. Is there another way to get an animated image sequence besides using gif? Or is there a way to set gif to a larger colorset/higher quality?

Thanks,
Dave

Re: Less lossy animated image sequence?

Posted: 2009-04-26T17:09:48-07:00
by fmw42
I am not a expert on animations, but see http://www.imagemagick.org/Usage/anim_opt/#color_opt and http://www.imagemagick.org/Usage/anim_opt/#optimize

and

then try

convert Complete_?.png miff:- | convert -delay 60 - -loop 0 animated.gif

I don't know if that will help or what he had in mind. Hopefully Anthony will see this later today and can clarify better or correct me.

The problem is likely that you have more than 256 colors combined from all the frames. Gifs are limited to a max of 256 colors.

Perhaps you may need to use +remap with some common color table. See http://www.imagemagick.org/script/comma ... .php#remap

Or +map. See http://www.imagemagick.org/Usage/video/#gif

I really don't understand the difference. Perhaps Anthony can clarify.

Re: Less lossy animated image sequence?

Posted: 2009-04-26T17:26:34-07:00
by daviddoria
I tried the miff thing and it's still pretty grainy. We'll see what Anthony has to say.

Re: Less lossy animated image sequence?

Posted: 2009-04-26T21:36:16-07:00
by anthony
It is hard to know what is going on without a sample.

If the images are real world video sequences, you can have a very BIG color problem.
this is look at in the video section (video to GIF animation)
http://www.imagemagick.org/Usage/video/#gif

If the images have a simple gradient of colours and one or two unique colors, you can get dither speckle, caused by the gradient suddenly have one very distant out lying color, adding some more outlying colors can solve that.
See http://www.imagemagick.org/Usage/quanti ... er_speckle

And then there is dither noise, cause by the psuedo-random dither pattern being different for each and every frame. the best solution here is to use ordered dither patterns. however order dither can not just take a 'best quantized color table, but currently only a mathematically generated color table.
Not a real good solution (still looking for an algorthing to order dither using a user supplied color table, I know they exist)

Then their is an on going but well known problem in that dither is currently selecting a limited number of colors from the 'best color' table from the color quantization. That is instead of getting an image with the full 256 colors quantize generated for it, the dither only used about 64 of those colors (not always the closest color). This is a known problem but one that requires a lot of work by someone with the knownledge of IM dither internals to take the time to trace it though to find the fault. Very annoying it is.

Re: Less lossy animated image sequence?

Posted: 2009-04-27T04:45:46-07:00
by daviddoria
Interesting, I never realized there were so many issues with gif.

Here is my example - watch the top right square:
http://www.rpi.edu/~doriad/SOCOM/HSV/HSV.gif

(the original images are here: http://www.rpi.edu/~doriad/SOCOM/HSV/)

In a couple of the frames, it is very "grainy" rather than a solid color.

Dave

Re: Less lossy animated image sequence?

Posted: 2009-04-27T20:56:17-07:00
by anthony
As the image does not have a lot of colors in it I am suprised you have that many problems.

I would first do is some frame optimization so only the color changing squares are modified in later images, leaving the static part only in the first frame. Those larger images should then only need 5x5 or 25 colors, As such no quantization or dithering should be needed for the second and later frames.

In fact if you quantize the squares separately to the rest first static image (just make the first frame use white for the squares and quantize down to leave at least 25 colors free), then you should be able to avoid any and all color problems. Of course each frame will have its own color table, but they should not need quantization (color reduction).

Divide and Conquer and you should avoid problems.




If this is for a web page you can make a "image table" with the static parts as separate images.
In fact as the squares are solid colors just generate a 5x5 pixel image and use HTML width and height image tags to set the final size. That will make your animation VERY VERY VERY small with no chance of dither noise at all!

For an example of an "imagetable" see...
http://www.cit.gu.edu.au/~anthony/wwwla ... rt/scroll/
and
http://www.cit.gu.edu.au/~anthony/wwwla ... rasterman/
though that was designed for a very old small browser window.

Also look at the other "HTML Art pages" in my WWW Lab
http://www.cit.gu.edu.au/~anthony/wwwlab/

remember 'view source' to see how it all works.