Automatically save a shape as an image file in Matlab

I create 49 shapes in Matlab, all of them are created automatically one by one. I want them to also be automatically saved as .tif or .jpg images with names corresponding to their number of digits. Can I do it? And if so, how?

code to create numbers:

 for num_picture=0:48 ... figure (num_picture+1) imshow (screen_im) end 

Part ... is all screen_im calculations.

I want these images to create a movie of them. If there is a way that I can automatically create a movie, Matlab, it would be nice too, in fact it would be better.

+4
source share
2 answers

You can save the current digit to a file with PRINT SAVEAS , generating a file name using a loop counter:

 saveas(sprintf('img%d.tif',num_picture)) 

or

  print('-dtiff','-r300',sprintf('img%d.tif',num_picture)) 
+8
source

To answer the second question, see avifile() . However, I was better off deleting frames individually (problems with compression quality, if I remember correctly).

To save individual frames, you can use imwrite() or print() with the -dpng option or similar. From there, use sprintf() to generate the file name with your frame number in it, and you have most of what you need. However, you will need a video editing program (VideoMach, etc.) to turn these frames into a movie if you are not using Matlab avifile ().

+1
source

Source: https://habr.com/ru/post/1337061/


All Articles