str = 'C:\'; %输入路径
strAll = '*.jpg';%输入图像格式设置
path = strcat(str, strAll);
file = dir(path);
for ii = 1 : length(file)
ImgPath = strcat(str, file(ii).name);
Img = imread(ImgPath); %读入图像
%%%%%%%%%%%%%%%%%%%%%%%
%你的代码
%%%%%%%%%%%%%%%%%%%%%%%%%%
end