matlab练习程序(求灰度图像最大灰度,最小灰度,平均灰度)
cl;
img=imread('15.bmp');
%imshow(img);
[m n]=size(img);
max=0;
min=256;
avg=0;
for i=1:1:m
for j=1:1:n
if img(i,j)<min
min=img(i,j);
end
if img(i,j)>max
max=img(i,j);
end
avg=avg+double(img(i,j));
end
end
%avg=mean(mean(img));
avg=uint8(avg/(m*n));
max
min
avg