how to make a video out of sequenced images in order

4 visualizaciones (últimos 30 días)
I have this code to make video file from a set of images. I have a folder with 1240 images numbered in order from 1 to 1240. But the video from the code does not start from the image1 but from the image numbered 1000 and goes till 1240 and starts from 1 to 999 again. I know that the reading of images from folder to matlab is going wrong somehow, but how to correct that?
What should I change in order for the video to start from image1 and go till the end. Appreciate the help.
if true
% % Make an avi movie from a collection of PNG images in a folder.
% Specify the folder.
myFolder = 'H:\My Documents\windowbanktests\tudMAT50M\images';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a directory listing.
filePattern = fullfile(myFolder, '*.PNG');
pngFiles = dir(filePattern);
% Open the video writer object.
writerObj = VideoWriter('YourAVI.avi');
writerObj.FrameRate = 10;
open(writerObj);
% Go through image by image writing it out to the AVI file.
for frameNumber = 1 : length(pngFiles)
% Construct the full filename.
baseFileName = pngFiles(frameNumber).name;
fullFileName = fullfile(myFolder, baseFileName);
% Display image name in the command window.
fprintf(1, 'Now reading %s\n', fullFileName);
% Display image in an axes control.
thisimage = imread(fullFileName);
imshow(thisimage); % Display image.
drawnow; % Force display to update immediately.
% Write this frame out to the AVI file.
writeVideo(writerObj, thisimage);
end
% Close down the video writer object to finish the file.
close(writerObj);
end

Respuesta aceptada

Image Analyst
Image Analyst el 18 de Oct. de 2018
  2 comentarios
YT
YT el 18 de Oct. de 2018
+1 this is actually pretty useful
Srinidhi Bindiganavile Ramadas
Srinidhi Bindiganavile Ramadas el 18 de Oct. de 2018
thank you @Image Analyst. very helpfull. Solved my problem

Iniciar sesión para comentar.

Más respuestas (1)

Community Treasure Hunt

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

Start Hunting!

Translated by