m+1,n-1)+W2(3,2)*fb(m+1,n)+W2(3,3)*fb(m+1,n+1));endend%中值滤波fa_midfilter=fa;fb_midfilter=fb;form=2:1:63forn=2:1:63fa_midfilter(m,n)=mid([fa(m-1,n-1),fa(m-1,n),fa(m-1,n+1),fa(m,n-1),fa(m,n),fa(m,n+1),fa(m+1,n-1),fa(m+1,n),fa(m+1,n+1)]);fb_midfilter(m,n)=mid([fb(m-1,n-1),fb(m-1,n),fb(m-1,n+1),fb(m,n-1),fb(m,n),fb(m,n+1),fb(m+1,n-1),fb(m+1,n),fb(m+1,n+1)]);endendfigure(1)subplot(1,2,1);imshow(fa);title('fa的图像');subplot(1,2,2);imshow(fb);title('fb的图像');figure(2)subplot(1,2,1);imshow(fa_avefilter);title('fa的平均滤波图像');subplot(1,2,2);imshow(fb_avefilter);title('fb的平均滤波图像');figure(3)subplot(1,2,1);imshow(fa_whtavefilter);title('fa的加权平均滤波图像');subplot(1,2,2);imshow(fb_whtavefilter);title('fb的加权平均滤波图像');figure(4)subplot(1,2,1);imshow(fa_midfilter);title('fa的中值滤波图像');subplot(1,2,2);imshow(fb_midfilter);