M=imread('dl011.jpg')%读取MATLAB中的名为cameraman的图像subplot(3,3,1)imshow(M)%显示原始图像title('original')P1=imnoise(M,'gaussian',0.02)%加入高斯躁声subplot(3,3,2)imshow(P1)%加入高斯躁声后显示图像title('gaussiannoise');P2=imnoise(M,'salt&pepper',0.02)%加入椒盐躁声subplot(3,3,3)imshow(P2)%%加入椒盐躁声后显示图像title('salt&peppernoise');g=medfilt2(P1)%对高斯躁声中值滤波subplot(3,3,5)imshow(g)title('medfiltergaussian')h=medfilt2(P2)%对椒盐躁声中值滤波subplot(3,3,6)imshow(h)title('medfiltersalt&peppernoise')l=[111%对高斯躁声算术均值滤波111111];l=l/9;k=conv2(P1,l)subplot(3,3,8)imshow(k,[])title('arithmeticfiltergaussian')%对椒盐躁声算术均值滤波d=conv2(P2,l)subplot(3,3,9)imshow(d,[])title('arithmeticfiltersalt&peppernoise')