MATLAB: How to generate a “movie” using a series of binary images

image processingvideo processing

I have a 3-D matrix where each x-y plane defines a binary image.
variable(:,:,1) calls image one; variable(:,:,2) is image 2 etc.
How can I generate a movie in MATLAB using each image as a frame? Also, how can I specify the frame-rate of this movie? Thanks in advance!

Best Answer

See my attached demo. The first half extracts frames from a movie and saves them to disk as individual images. The second half reconstructs the video by reading in those images and using VideoWriter it makes a video file. You can just do that, though you won't have to call imread() since your frames are already in memory.
Related Question