代码中的路径按需更改
- % % fig --> jpg
- % r = 'H:\PersonalProducts\astronaut\human.gif';
- % info = imfinfo(r);%第一次读取,用于获取属性值
- % W = info.Width;
- % H = info.Height;
- % W = W(1);
- % H = H(1);
- % len = length(info);%总帧数
- % for i = 1 : len %截取每一帧
- % [Ii, map] = imread(r, 'frames', i); %将第i帧保存为索引格式
- % I2 =ind2rgb(Ii,map); %最关键的,将索引转为RGB格式!
- % imwrite(I2,strcat('H:\PersonalProducts\astronaut\output\astronaut_',num2str(i,'%02d'),'.','png'));
- % end
- % mp4 --> jpg
- apple='H:\PersonalProducts\astronaut\astronaut.mp4';
- obj = VideoReader(apple);
- for i=1 : 60 %视频3秒,每秒30帧
- astronaut = read(obj,i);
- imwrite(astronaut,strcat('H:\PersonalProducts\astronaut\output\',num2str(i,'%02d'),'.','png'));
- end
|