Animate: issue with color artifacts

asked 2023-05-07 18:40:05 +0100

Will Orrick gravatar image

updated 2023-05-11 21:03:40 +0100

I have an animation consisting of relatively simple moving shapes - mostly solid black polygons. When I render the animation using

myAnimation = animate(myListOfFrames)

I see bright yellow color along the leading edges of some of the black polygons. ("Leading edge" is defined with respect to the direction of motion. Specifically my figure is moving to the left with a combination of translational and counterclockwise rotational motion and I am seeing the yellow along the top left portions of the polygons in the top left part of the figure. I also smaller yellow effects in other parts of the figure.)

When I inspect the frames one-by-one using, for example,


I do not see the yellow. Since imagemagick is used by default for showing animations, I thought it might be an imagmagick effect, so I tried


instead, but still found the same thing.

I surmise this might have something to do with the limited color palette in converting to .gif format. Are there any options for show() or animate(), or for imagemagick or ffmpeg more generally that users can play with through sage? Or any suggestions really for getting around this issue.

Update: I now have reason to believe that my setup is defaulting to the use of ffmpeg for all processing, even when use_ffmpeg is not set to True, so ImageMagick seems not to be to blame. (The ImageMagick installation on my MacBook Pro running Ventura is somehow broken, and reinstallation does not fix it. Also some diagnostics indicate that the system calls sage is making are all to ffmpeg.)

I've also discovered that running myAnimation.ffmpeg(), which produces a .mpg file instead of a .gif, gives much nicer output, with no artifacts. I can even use ffmpeg from the command line to convert the resulting .mpg file to a .gif, and the .gif I get is also free of artifacts.

This suggests that it is not ffmpeg itself that is responsible for the artifacts, but instead something about how ffmpeg is being used by sage in the process of generating a .gif directly.

edit retag flag offensive close merge delete


Ideally, provide an actual example others can run.

slelievre gravatar imageslelievre ( 2023-05-19 22:49:37 +0100 )edit