Hi all. I want to convert 2D(x,y) images to video. Can anyone please help me out to solve this. I want a solution ASAP. Thank you.

 채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 5일

0 개 추천

Use the videowriter class. There are examples http://www.mathworks.com/help/matlab/ref/videowriter-class.html

댓글 수: 3

Zainb
Zainb 2015년 6월 8일
Thank you @Walter for your answer, I'm new to matlab almost, I'm just unable to use this class to write video in my case. I don't understand how to give frames to object. I'v a folder containing images , i want to writer video after reading these frames from this folder. Will you pleas help me out. Thanks again!
writerObj = videowriter('OutFile.avi');
writerObj.Framerate = 30;
fileinfo = dir('*.jpg'); %get list of files in current directory
for K = 1 : length(fileinfo)
thisfilename = fileinfo(K).name; %current file name
thisimage = imread(thisfilename); %read image from file
writeVideo(writerObj, thisimage); %a frame is an image
end
close(writerObj);
Note: if you named your files things like frame1.jpg, frame2.jpg, ... frame10.jpg, frame11.jpb, then you will encounter problems with this short code, as it will do them in the order frame1.jpg, frame10.jpg, frame11.jpg, frame2.jpg, .. frame9.jpg as that is the order that the names sort into. There are routines in the File Exchange that can understand "natural" order of files that should have been created with leading 0's in the name, frame0001.jpg, frame0002.jpg, frame0010.jpg and so on.
Zainb
Zainb 2015년 6월 24일
Wow! it worked for me, Thank you a lot :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 6월 9일

0 개 추천

Attached is a demo. It extracts frames from a video to separate image files, then it reverses the process, going from separate image files to a video, basically using the process Walter showed.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

질문:

2015년 6월 5일

댓글:

2015년 6월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by