视频转图片,图片取大小
clc;clear;
obj=VideoReader('双闪.avi');
numFrames = obj.NumberOfFrames;% 帧的总数
for i=1:numFrames
im = read(obj,i);%读取第几帧
aaa=imresize(im,[628,800]);%设置图片大小
ae=aaa(21:548,:,:);%取RGB图片的一部分
%保存为 *.tif 图
imwrite(ae, ['D:\MATHWORKSHOP\vedio12\' num2str(i) '.tif']);
end
Excel文件的读写:
读:
[NUM,TXT,RAW]=xlsread('datacombinALL_20161103_01.xlsx',1,'A2:AQ329879');
写:
xlswrite('NewNoRepeat_20161104_01.xlsx',data,1,'A1');
excel2text:
ExcelPath = 'excelData/';
TextPath = 'textData/';
secondFile = dir(fullfile(ExcelPath,'*'));
secondFile = struct2cell(secondFile);
[~,n] = size(secondFile);
for excel_id=1:n-2
[NUM,TXT,RAW]=xlsread(strcat(ExcelPath,'A_',num2str(excel_id),'.xlsx'));
fp = fopen(char(strcat(TextPath,'Txt_',num2str(excel_id),'.txt')),'wt');
for txt_id=1:max(size(RAW))
fprintf(fp,'%s%c\n',char(TXT{txt_id,1}),'');%写入字符 写入换行符
end
fclose(fp);
disp_excel_id=char(strcat('excel_id=',num2str(excel_id)));
disp( disp_excel_id);
end
按文件夹读取文件
path = 'F:/MATLAB_workSpace/AIUI_challenge_cup/dataExcel/';
%% 读取文件夹 n-1
firstFile = dir(fullfile(path,'*'));
firstFile = struct2cell(firstFile);
firstnum = size(firstFile);
for firstk =0:firstnum(2)-1
firstx(firstk+1) = firstFile(1,firstk+1);
end
ExcelPath = cell(1,1);
%% 进一步读取文件夹里面的内容
for firstk = 1:firstnum(2)
if ~strcmp(char(firstx(firstk)),'.')
if ~strcmp(char(firstx(firstk)),'..')
newpath = char(strcat(path,'',firstx(firstk),'/'));
ExcelPath{firstk-2,1}= newpath;
end
end
end
save ExcelPath ExcelPath
disp('路劲获取完成')
text2mat
load('matFile/MatLin.mat');%把旧的数据取出来达到追加写 的效果
s{x,1} = load('matFile/LTLDescribeVector.utf8');
s{x,2} = load('matFile/LTLResultVector.utf8');
% s{x,3} = load('src/LTLCX.utf8');
s{x,4} = importdata('matFile/LTLC.utf8');
save('matFile/MatLin.mat','s');
clear s
热门评论
谢谢分享~运行试一试~哈哈