Hello !
I have about 500 pics and i'd like to make a video with. Also, i have a vector with the time each image should appear. (Img10 at tome(10))
Is it possible ?
Thank you so much, Loic.

2 comentarios

Matthew Eicholtz
Matthew Eicholtz el 27 de Abr. de 2016
Yes, this should be possible. Is the frame rate constant?
Riva
Riva el 2 de Abr. de 2025
Eu também tenho interesse nesse algoritmo.. A taxa pode ser constante sim.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 27 de Abr. de 2016
Editada: Image Analyst el 27 de Abr. de 2016

4 votos

I was doing almost the same thing today. I'm still in the act of polishing it up, but here is a first draft that works, attached. You specify a folder of images and it builds all the images into an avi movie. You can specify the frame rate, and how many times the first slide shows up (because it might be a title slide).
You could use text() to imprint any text on the frames, such as the time or whatever.
I'm using it to make a time lapse movie of a building they're building here. It will take 3 years to finish the building. I take a picture every day that I'm there. Eventually I also want to figure out how to place each frame at the proper time, but right now it just strings them all together. Feel free to modify it though to do what you want, which will require you writing additional copies of frames in there to make sure the frame you want appears at the proper time.

12 comentarios

Nidhi Kumari
Nidhi Kumari el 11 de Jul. de 2018
can you please provide me with the code?
Turlough Hughes
Turlough Hughes el 11 de Oct. de 2019
Did you finish the timelapse??
Image Analyst
Image Analyst el 12 de Oct. de 2019
There have been some changes since 2016. I'm attaching the latest.
Batuhan Buyukkoroglu
Batuhan Buyukkoroglu el 8 de Mzo. de 2020
Hi Image Analyst. I ran your code, then this window opened. But i can not convert that image sequence to a video. I took an error(Error in program makeMovie, function btnAnalyze_Callback(), at line 493. Error Message: Undefined function 'object' for input arguments of type 'char'). I tried to run this code with another image sequence, program converted that sequence to a video, but i can't play the video because of it's format. What should i do?
Image Analyst
Image Analyst el 8 de Mzo. de 2020
That's really weird. Line 493 is a comment:
% Main processing is done by the function AnalyzeSingleImage()
and should not throw an error. Did you alter the function in any way? Look especially at the first line of the m-file - does it look normal? Please attach your m-file so I can inspect it. Or else you can extract it again to a different folder and use the file comparison utility in MATLAB to check for differences.
Batuhan Buyukkoroglu
Batuhan Buyukkoroglu el 10 de Mzo. de 2020
In my code, 493. line is "object to write the video out to a new, different file." Can you send me the latest version sir?
Batuhan Buyukkoroglu
Batuhan Buyukkoroglu el 11 de Mzo. de 2020
In code that i used, " Main processing is done by the function " comment is at line 471.
Adam Rajcan
Adam Rajcan el 20 de Nov. de 2020
Dear Image Analysts
I have a problem using your script. It does not allow me to change the ordering style. Using the predefined ordering style orders our images like 1,10,100,1000,1001,1002 ... Any idea how can we solve it?
Thank you for your extensive work, we have been using from your scripts for a while already.
Image Analyst
Image Analyst el 20 de Nov. de 2020
You'll have to call a routine to sort the items in the listbox in that way. See this link:
Kyle Uhlenhake
Kyle Uhlenhake el 14 de Jun. de 2021
I might be missing something simple, but whenever I pull up makeMovie.fig and try to select an image folder I get the following error:
Any help would be great!
Thanks
Image Analyst
Image Analyst el 11 de Sept. de 2022
@Kyle Uhlenhake I just ran it again and it worked find. Line 425 is this:
returnValue = uigetdir(handles.imageFolder,'Select folder');
The error message means that imageFolder is not a field of handles. That means you must have somehow modified handles, perhaps in the OpeningFcn. Try to download again and run it. Otherwise try this workaround (which is also in the code attached here).
try
returnValue = uigetdir(handles.imageFolder,'Select folder');
catch
returnValue = uigetdir(pwd,'Select folder');
end
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
atharva aalok
atharva aalok el 15 de Sept. de 2022
Editada: atharva aalok el 15 de Sept. de 2022
@Image Analyst I am using your code for making a movie.
I have a folder with 40 png images. I want to use these to make my movie.
When I run the makeMovie.fig
After selecting the folder I get the following error messages in succession:
What could be wrong here?
(I have aleady added the following lines to the .m file at line 425 as suggested in a previous comment:
try
returnValue = uigetdir(handles.imageFolder,'Select folder');
catch
returnValue = uigetdir(pwd,'Select folder');
end
)
Images in my folder are named as follows:

Iniciar sesión para comentar.

Más respuestas (5)

Matthew Eicholtz
Matthew Eicholtz el 27 de Abr. de 2016

5 votos

I usually use the VideoWriter class for making movies in MATLAB.
Here is some basic code structure to get you started:
video = VideoWriter('yourvideo.avi'); %create the video object
open(video); %open the file for writing
for ii=1:N %where N is the number of images
I = imread('the ith image.jpg'); %read the next image
writeVideo(video,I); %write the image to file
end
close(video); %close the file
Now, this assumes constant frame rate (which can be set using the video.FrameRate property). I am not aware of any built-in functionality for handling variable frame rate. But, in theory, you could hack it by repeating image frames.
For example, if your frame rate is 1 frame per second, and the time vector is something like:
t = [0 2 3 7 ...]; %times for the 1st image, 2nd image, and so forth
Then, you will want to call 'writeVideo(video,I)' 2 times for image 1, 1 time for image 2, 4 times for image 3, etc. This will be challenging if your times are not multiples of your frame rate, so watch out for that.

6 comentarios

Shafi Ullah
Shafi Ullah el 5 de En. de 2020
I need a code for making video from image. The following code is not working...
Image Analyst
Image Analyst el 5 de En. de 2020
Did you look at my latest comment. That code works. Why don't you try it?
Spandana M
Spandana M el 20 de Jul. de 2020
Your file is too big Image Analyst....I know maybe its very detailed and would be very efficient,but I have no time to through whole of it and undertstans and then apply T.T
Nidhish Jain
Nidhish Jain el 4 de Mzo. de 2021
@Matthew Eicholtz I followed your code and I got the avi file. But the video is all black. I don't know what is happening. I can see the images in the video but somehow they are all filtered to black. Please let me know if you know anything about this.
Image Analyst
Image Analyst el 4 de Mzo. de 2021
Try my code instead. If that still doesn't work, then start a new question and attach 5 of your images.

Iniciar sesión para comentar.

Pascal Stirtzel
Pascal Stirtzel el 30 de En. de 2020

1 voto

Perfect, thank you very much
Vikas Arora
Vikas Arora el 11 de Sept. de 2022
Editada: Image Analyst el 11 de Sept. de 2022

1 voto

A small modification to @Matthew Eicholtz's answer:
% If your image file starts with image_1.png, image_2.png and so on ...
% and live in the current folder.
folder = pwd; % Or wherever you want.
video = VideoWriter('yourvideo.avi'); % Create the video object.
open(video); % Open the file for writing
N=601; % Where N is the separate number of PNG image files.
for k = 1 : N
I = imread(fullfile(folder, sprintf('image_%g.png', k))); % Read the next image from disk.
writeVideo(video,I); % Write the image to file.
end
close(video);

3 comentarios

atharva aalok
atharva aalok el 15 de Sept. de 2022
The file appears but when I play it says:
"This item is in a format we don't support."
S Ch
S Ch el 27 de Oct. de 2022
@atharva aalok Read it using Windows Media.
Image Analyst
Image Analyst el 28 de Oct. de 2022
@atharva aalok try a different file extension, like .mp4 or .mpg or .wmv.

Iniciar sesión para comentar.

AMIT SURYAVANSHI
AMIT SURYAVANSHI el 15 de En. de 2024

0 votos

% Example data
imageFolder = 'path_to_your_images'; % Replace with the actual path to your image folder
imageFiles = dir(fullfile(imageFolder, '*.jpg')); % Change the extension based on your image format
numImages = length(imageFiles);
% Vector with time each image should appear (in seconds)
timeVector = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; % Adjust the timings as needed
% Create a VideoWriter object
outputVideo = VideoWriter('outputVideo.mp4', 'MPEG-4');
outputVideo.FrameRate = 1; % Adjust the frame rate as needed
open(outputVideo);
% Loop through each image and write it to the video
for i = 1:numImages
% Read the current image
currentImage = imread(fullfile(imageFolder, imageFiles(i).name));
% Write the current image to the video
writeVideo(outputVideo, currentImage);
% Pause for the specified time
pause(timeVector(i));
end
% Close the video file
close(outputVideo);

Preguntada:

el 23 de Abr. de 2016

Comentada:

el 2 de Abr. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by