Azzera filtri
Azzera filtri

Generating gifs that replay and controlling FPS in MATLAB

84 visualizzazioni (ultimi 30 giorni)
I'm generating lots of figures representing a system and it would be useful to be if they were displayed in a GIF (so I don't have to keep clicking between them, they just skip automatically).
I'v been able to create a GIF using the exportgraphics command, the issues are:
1) it doesn't replay. After it has finished showing each image, it stops on the last image and thats it. I've tried saving and reloading, but the GIF stays stuck on the last image. I need to be able to save the file as a GIF to use with other software.
2) the FPS is really low. Ideally I'd like it to be about 50 frames over 2 seconds.
I'm using MATLAB online, I don't know if that helps

Risposte (2)

Eshan Patel
Eshan Patel il 4 Nov 2022
Hey William,
I see that you are using "exportgraphics" to create a GIF, and you require a better way to do it. You can address all the drawbacks you are currently facing by using the "imwrite" function, which will allow you to loop the GIF and add a custom delay to each frame.
Please have a look at the "Write Animated GIF" example in the documentation for "imwrite".

DGM
DGM il 4 Nov 2022
I don't have exportgraphics(), so I can't experiment with it, and I'm not sure how you're using it.
Off the top of my head, I don't recall how the loopcount is specified in the file header for GIF. My suspicion is simply that the way the file is being incrementally constructed is creating a problem.
That said, I use these tools for creating animated GIFs from 4D image arrays. You might have to do some extra intermediate work to get the images in that form, but that's what I have at hand. That'll handle per-frame delay specification, and it's infinite-looping by default.
There are other GIF tools on the FEX, but those are the ones I'm familiar with (because I wrote them).

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Tag

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by