%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% method 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
uigetdir(目录对话框)获得目录名
dir(dirname)函数返回的就是目标文件夹内的所有的文件
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% method 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Matlab批量处理图像思路
%% Matlab批处理图像框架
%--------------------------------------------------------------------------------------------------
% 此m文件是批量处理图像的框架
% 2009.10.12 shine shuchong1987@sina.com
%--------------------------------------------------------------------------------------------------
%% 命令集
t = cd('xxxxx'); %
dos命令cd重置当前路径,自行设置,其下包含全部待处理文件
allnames = struct2cell(dir); %
dos命令dir列出所有的文件,用struct2cell转换为元胞数组
[m,n] = size(allnames);
for i= 3:n %
从3开始。前两个属于系统内部。
name = allnames{1,i} % 逐次取出文件名
filename = [t,'',name] % 组成文件名
I = imread(filename); % 本人测试了一下,imread要比importdata效率高一些
//Do your own work
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
copyfile ---拷贝文件或文件夹
syntax:
copyfile('source','destination')
copyfile('source','destination','f')
[status] = copyfile(...)
[status, message] = copyfile(...)
[status,message,messageid] = copyfile(...)
See Also