Message Boards Message Boards

Generate smooth animations?

Posted 4 years ago

I love using Graphics[] in Mathematica. For the most part, it does a great job, and is easy to use. However, when creating animations, its images tend to be "jittery" on playback. For example, a single vertical line moving to the right:

frames = ParallelTable[Rasterize[Graphics[
     Line[{{a, 0}, {a, 1}}],
     PlotRange -> {{0, 0.1}, {0, 1}}
     ]], {a, 0, 0.1, 0.001}];
ListAnimate[frames]

enter image description here

When viewed in-notebook or exported, the animation tends to "throb" or "blink", at any magnification. Does anyone else experience this issue and have insight on how to deal with it?

POSTED BY: Sam M
3 Replies
Posted 4 years ago

The problem seems to persist regardless of the choice of raster size, image size, or without calling Rasterize[] at all.

POSTED BY: Sam M

Hi Sam,

I guess you see this effect because your vertical line runs parallel to the pixel columns of your screen, and this can be problematic. (E.g. in digital radiology this is a known pitfall - one always makes sure that field borders are somewhat rotated against pixel rows/columns.) And in fact when you do the same using a non-vertical line the effect is basically gone:

frames = ParallelTable[
   Graphics[Line[{{a, 0}, {a + .1, 1}}], 
    PlotRange -> {{0, 0.21}, {0, 1}}], {a, 0, 0.1, 0.001}];
ListAnimate[frames]
POSTED BY: Henrik Schachner

I do not know the reason but will note that some options to Rasterize have Automatic settings. Possibly giving explicit values to e.g. ImageSize might help.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract