我试图从 png 文件制作视频,它们应该在制作视频时按顺序排列,它放图像 test_1,下一个 test_10,但我需要是 test_1、test_2、test_3 ......如果我排序%sort_nat({images.name}); 稍后我会收到一个错误,这种类型的变量不支持点索引。任何评论将不胜感激。这是脚本:
clear all; clc;close all;
path = 'D:/Neda/Pytorch/U-net/plots_U_Net/CineLoop';
filePattern = fullfile(path, '*.png');
imgfileattrib = dir(filePattern); %attributes
images = {imgfileattrib.name}; %list of images
[~, ind] = sort(str2double(regexprep(images,'[^0-99]',''))); %sorted indices
images = images(ind);
writerObj = VideoWriter('YourAVI.avi');
writerObj.FrameRate=1;
open(writerObj);
for frameNumber = 1 : length(images)
baseFileName = images(frameNumber);
fullFileName = fullfile(path, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
thisimage = imread(fullFileName);
imshow(thisimage);
drawnow;
writeVideo(writerObj, thisimage);
end
close(writerObj);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句