Downsampling a selection of images before converting them to video

2 visualizaciones (últimos 30 días)
I'm trying to create an .avi file from several .tif images, due to the very large number of images and the high frame rate I need to only use every other frame so that instead of 80 fps I get 40 fps. for example if there are images named 1, 2, 3, 4, 5, 6 etc, I only need images 1, 3, 5 in the video. This is the code I'm using so far:
function tif2avi
clc; close all;
[imagelist,p]=uigetfile('*.tif','MultiSelect','on',...
'Select LIST to plot'); pause(0.5); cd(p);
if ~iscell(imagelist); disp('imagelist not cell'); return; end;
outputVideo = VideoWriter('0424_rat01.avi');
outputVideo.FrameRate = 80;
outputVideo.Quality = 50;
open(outputVideo);
for i=1:numel(imagelist)
img=imread(imagelist{i});
writeVideo(outputVideo,img);
end

Respuesta aceptada

Chandra
Chandra el 5 de Mayo de 2022
Hi,
try using "imresize" function in the "for" loop
for i=1:numel(imagelist)
img=imread(imagelist{i});
img = imresize(img,[1920 911]); % change the values accordingly, find the size in outputVideo using workspace or command window
writeVideo(outputVideo,img);
end
close(outputVideo);
try to explore outputVideo from workspace and change the required values accordingly.

Más respuestas (0)

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by