.tiff to .avi conversion

4 次查看(过去 30 天)
Shubhi Sharma
Shubhi Sharma 2020-1-8
I have a sequence of .tiff images and need to convert it into an .avi file. Can anyone provide the matlab code for the same.

回答(1 个)

Mann Baidi
Mann Baidi 2024-5-2
As per my understanding of the question, you would like to create an .avi file using a sequence of .tif images in MATLAB.
I would sugget you to use the 'VideoWriter' object to create a video object and then can add the frames using the 'writeVideo' function.
You can take help of the following code as a reference.
% Specify the folder where your .tif file is located
folder = pwd;
% List all files in the folder
files = dir(fullfile(folder, '*.tif'));
% Check if any .tif files are found
if isempty(files)
error('No .tif files found in the specified folder');
end
% Create a Video Writer Object for .avi video file
v = VideoWriter('new.avi','Uncompressed AVI');
% numFiles contains the number of .tif files in the folder
numFiles=numel(files);
open(v);
for k=1:numFiles
% Reading each tif file one by one and adding it in the video
x=imread(files(k).name);
v.writeVideo(x);
end
close(v);
% Play the .avi file
implay('new.avi')
You can know more about the 'VideoWriter' object using the documentation link mentioned below:

Community Treasure Hunt

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

Start Hunting!

Translated by