Making a video by selecting png images

2 ビュー (過去 30 日間)
Joydeb Saha
Joydeb Saha 2021 年 9 月 8 日
回答済み: Image Analyst 2021 年 9 月 8 日
How can I make a video by selecting png images from a folder? Also how can I save the video?
the files are: abc_20190304_0001.png to abc_20190304_0095.png

回答 (2 件)

Walter Roberson
Walter Roberson 2021 年 9 月 8 日
Loop over the files by constructing their names. Or read the directory and loop over the files returned by dir().
A common challenge when using information returned by dir() is that numbers are usually sorted in an order people do not expect. abc1.png abc10.png abc11.png abc12.png ... abc19.png abc2.png abc20.png abc21.png and so on. However, I see that in your case the filenames use 4 digit number suffixes with 0 fill, and under that circumstance, you can use the order returned by dir() [though in theory you should sort() the file names, in practice you do not need to if you are using NTFS or any of the common Mac or Linux file systems.]
Use videoWriter() to create a movie object. Read one input file at a time and writeVideo() it to the movie object. https://www.mathworks.com/help/matlab/ref/videowriter.html

Image Analyst
Image Analyst 2021 年 9 月 8 日
I do this in the attached example. I take a video and then write all the frame to disk as individual files. Then I reconstruct a new image by reading in all the frames from the disk and making them into a new movie/video.

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by