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

8 ビュー (過去 30 日間)
Abdallah Almahmoud
Abdallah Almahmoud 2022 年 5 月 4 日
回答済み: Geoff Hayes 2022 年 5 月 5 日
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);

回答 (1 件)

Geoff Hayes
Geoff Hayes 2022 年 5 月 5 日
@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);

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by