path = 'E:\Personal\Desktop\1';
newpath1 = 'E:\Personal\Desktop\2';
mkdir(newpath1);
file = dir(path);
for k = 3:length(file)
img = imread([path,'\',file(k).name]);
[m,n] = size(img);
for x = 1:m
for y = 1:n
img(x,y) = 255-img(x,y);
end
end
newname = [newpath1,'\',file(k).name];
imwrite(img,newname)
end
转载于:https://www.cnblogs.com/j657521265/p/8150132.html