How To Create Video From Sequence of Images Using MATLAB?
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
% Create Video with Image Sequence clear all clc % Designate the path below as the current folder. CD( 'E:\Documents and Settings\APPEX\My Documents\MATLAB\Images' ); % Get all of the files in the current % folder that are in JPEG format. Files = dir( '*.jpg' ); % The current folder's number of JPEG files NumFiles= size(Files,1); % To write Video File VideoObj = VideoWriter( 'Create_Video.avi' ); % Number of Seconds Between Frames VideoObj.FrameRate = 6; % Define the Quality of the Video [ 0 to 100 ] VideoObj.Quality = 70; % Open the File 'Create_video.avi' open(VideoObj); for i = 1 : NumFiles % Take a Look at the Image in the Present Folder. I = imread(Files(i).name); % Resize Image ResizeImg = imresize(I,[500 900]); % Convert a picture into a movie frame frame = im2frame(ResizeImg); % Six times are written on each Frame. for j = 1 : 6 % Write a frame writeVideo(VideoObj, frame); end end % Close the File 'Create_Video.avi 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.
Please Login to comment...