www.gusucode.com > 《matlab图像处理与界面编程宝典》秦襄培 编著,每章的MATLAB源代码程序 > 第14章/代码14-2.txt

    
I = im2double(imread('tire.tif'));           % 读入图像
f1 = @(x) ones(64,1)*mean(x);                % 设定处理函数为mean
f2 = @(x) ones(64,1)*max(x);                 % 设定处理函数为max
f3 = @(x) ones(64,1)*min(x);                 % 设定处理函数为min
I2 = colfilt(I,[8 8],'distinct',f1);         % 图像块处理
I3 = colfilt(I,[8 8],'distinct',f2);         % 图像块处理
I4 = colfilt(I,[8 8],'distinct',f3);         % 图像块处理
figure,imshow(I2);                           % 函数mean处理后的图像
figure,imshow(I3);                           % 函数max处理后的图像
figure,imshow(I4);                           % 函数min处理后的图像