.tiff to .avi conversion

조회 수: 4 (최근 30일)
Shubhi Sharma
Shubhi Sharma 2020년 1월 8일
답변: Mann Baidi 2024년 5월 2일
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