How To Create Video From Sequence of Images Using MATLAB?
Last Updated :
28 Jan, 2023
MATLAB stands for Matrix Laboratory. It is a high-performance language that is used for technical computing. In this article, we will see how to add subtitles to videos in MATLAB.
In the First step We will read the image after that we convert it to a movie frame and then write each frame one by one to the video file in this section. we take a example for creating video from sequence of images.
Example 1:
Matlab
clear all
clc
the current folder.
CD( 'E:\Documents and Settings\APPEX\My Documents\MATLAB\Images' );
Files = dir( '*.jpg' );
NumFiles= size(Files,1);
VideoObj = VideoWriter( 'Create_Video.avi' );
VideoObj.FrameRate = 6;
VideoObj.Quality = 70;
open(VideoObj);
for i = 1 : NumFiles
I = imread(Files(i).name);
ResizeImg = imresize(I,[500 900]);
frame = im2frame(ResizeImg);
for j = 1 : 6
writeVideo(VideoObj, frame);
end
end
close(VideoObj);
|
Output:
Use the “im2frame” function to convert the image to a movie frame after reading the image from the current folder. Until the last image has been processed and written, write the frame to the file, read the next image, and repeat the process.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...