資源描述:
《算術(shù)均值濾波和幾何均值濾波.pdf》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、算術(shù)均值濾波代碼:clearall;I=zeros(244,233);fori=18:226forj=1:233fork=1:9if24*k-7<=j&&j<=24*kI(i,j)=255;endendendendsubplot(2,2,1),imshow(I),title('原始圖像');K1=filter2(fspecial('average',3),I)/255;K2=filter2(fspecial('average',7),I)/255;K3=filter2(fspecial('average',9),I)/255;subplot(2,2,2),imshow(K1),title(
2、'3*3算術(shù)均值濾波圖像');subplot(2,2,3),imshow(K2),title('7*7算術(shù)均值濾波圖像');subplot(2,2,4),imshow(K3),title('9*9算術(shù)均值濾波圖像');原始圖像3*3算術(shù)均值濾波圖像7*7算術(shù)均值濾波圖像9*9算術(shù)均值濾波圖像幾何均值濾波代碼:clear;I=zeros(244,233);fori=18:226forj=1:233fork=1:9if24*k-7<=j&&j<=24*kI(i,j)=1;endendendendsubplot(2,2,1),imshow(I),title('原始圖像');F=I;G=I;H=I
3、;N=I;M=I;fori=2:243;forj=2:232;P=F(i-1:i+1,j-1:j+1);X=prod(prod(P),2);I(i,j)=X^(1/9);endendsubplot(2,2,2),imshow(I),title('3*3幾何均值濾波圖像');fori=4:241;forj=4:230;P=F(i-3:i+3,j-3:j+3);X=prod(prod(P),2);H(i,j)=X^(1/49);endendsubplot(2,2,3),imshow(H),title('7*7幾何均值濾波圖像');fori=5:240;forj=5:229;P=N(i-4:i+
4、4,j-4:j+4);X=prod(prod(P),2);M(i,j)=X^(1/81);endendsubplot(2,2,4),imshow(M),title('9*9幾何均值濾波圖像');原始圖像3*3幾何均值濾波圖像7*7幾何均值濾波圖像9*9幾何均值濾波圖像