how can I convert Tiff images with different timepoint to Mp4?
8 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!