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!