making video from large number of images
조회 수: 7 (최근 30일)
이전 댓글 표시
hi every body.
I have 368 images in a folder. i nead to make a video from them. i hav find a mathlab code by search, but i have an error in line 19, (frame = im2frame(pic{u})). and also i dont know how can i fix "secsPerImage" in line 13 for all 368 images equal to 2 seconds per image.
could anyone help me please?
surf_read_dir='E:\phd\shadi gholipoor\shadi gholipoor jpg\Series_10448_70.0%\';
files=dir('E:\phd\shadi gholipoor\shadi gholipoor jpg\Series_10448_70.0%\*.jpg');
for im=1:size(files)
fdir = strcat(surf_read_dir , files(im).name);
slice_im = load(fdir);
pic = imread(fdir);
end
writerObj = VideoWriter('myVideo.avi');
writerObj.FrameRate = 1;
% set the seconds per image
% secsPerImage = [5 10 15];
% open the video writer
open(writerObj);
% write the frames to the video
for u=1:length(pic)
% convert the image to a frame
frame = im2frame(pic{u});
for v=1:secsPerImage(u)
writeVideo(writerObj, frame);
end
end
% close the writer object
close(writerObj);
댓글 수: 0
답변 (1개)
KALYAN ACHARJYA
2020년 12월 29일
One error I have need notiching that, at the initial loop, you consider "pic" as single variable. However, in the 2nd loop, it is called as as cell array, it might be-
for im=1:size(files)
.....
pic{im}= imread(fdir);
end
A lot of similar question answers are available in MATLAB Answers (call sequence of images), and the later part converts them into frames using the im2frame function.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!