how can I convert Tiff images with different timepoint to Mp4?

8 visualizaciones (últimos 30 días)
Abdallah Almahmoud
Abdallah Almahmoud el 4 de Mayo de 2022
Respondida: Geoff Hayes el 5 de Mayo de 2022
v = VideoWriter('test_c_file.mp4', 'MPEG-4');
open(v);
for k = 0:100 % assumes 10 images to write to file
%tmp = randi(255, 100, 200, 'uint8');
t = Tiff([folder 'test_27_Hour_00_Minute_00_Second_00_Frame_00; test_27_Hour_00_Minute_00_Second_01_Frame_00; test_27_Hour_00_Minute_00_Second_02_Frame_00; test_27_Hour_00_Minute_00_Second_03_Frame_00; test_27_Hour_00_Minute_00_Second_04_Frame_00; test_27_Hour_00_Minute_00_Second_05_Frame_00' num2str(k) '.tif'], 'r');
tmp = read(t);
writeVideo(v, tmp);
end
close(v);

Respuestas (1)

Geoff Hayes
Geoff Hayes el 5 de Mayo de 2022
@Abdallah Almahmoud - are you trying to read multiple TIFF files with
t = Tiff([folder 'test_27_Hour_00_Minute_00_Second_00_Frame_00; test_27_Hour_00_Minute_00_Second_01_Frame_00; test_27_Hour_00_Minute_00_Second_02_Frame_00; test_27_Hour_00_Minute_00_Second_03_Frame_00; test_27_Hour_00_Minute_00_Second_04_Frame_00; test_27_Hour_00_Minute_00_Second_05_Frame_00' num2str(k) '.tif'], 'r');
? If I try something like this, then there is the following error
Error using Tiff (line 653)
Could not open file '\<some folder>\test_27_Hour_00_Minute_00_Second_00_Frame_00;
test_27_Hour_00_Minute_00_Second_01_Frame_00; test_27_Hour_00_Minute_00_Second_02_Frame_00;
test_27_Hour_00_Minute_00_Second_03_Frame_00; test_27_Hour_00_Minute_00_Second_04_Frame_00;
test_27_Hour_00_Minute_00_Second_05_Frame_001.tif'.
I think that you need to iterate over each file instead. Perhaps something like
v = VideoWriter('test_c_file.mp4', 'MPEG-4');
open(v);
images = {'test_27_Hour_00_Minute_00_Second_00_Frame_00'; 'test_27_Hour_00_Minute_00_Second_01_Frame_00'; ...
'test_27_Hour_00_Minute_00_Second_02_Frame_00'; 'test_27_Hour_00_Minute_00_Second_03_Frame_00'; ...
'test_27_Hour_00_Minute_00_Second_04_Frame_00'; 'test_27_Hour_00_Minute_00_Second_05_Frame_00'};
for k = 0:100 % assumes 10 images to write to file
for j = 1:length(images)
t = Tiff(fullfile(folder,[images{j} num2str(k) '.tif']), 'r');
tmp = read(t);
writeVideo(v, tmp);
end
end
close(v);

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by