资源描述:
《阿尔法均值滤波》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.图像复原的目的是从观测到的退化图像重建原始图像,它是图像处理、模式识别、机器视觉等的基础,在天文学、遥感成像、医疗图像等领域获得了重要应用。代码:I=imread('g.png');[m,n]=size(I);P=imnoise(I,'salt&pepper',0.04);Q=imnoise(I,'gaussian',0,0.02);R=imnoise(P,'gaussian',0,0.02);%加椒盐噪声的三种情况A=I;%d=0d=0;fori=2:m-1forj=2:n-1img_turn=P(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(
2、:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));A(i,j)=sum(img_decrese(:))/(9-d);endendB=I;%d=2d=2;fori=2:m-1forj=2:n-1img_turn=P(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));B(i,j)=sum(img_decrese(:))/(9-d);endendC=I;%d=4d=4;fori=2:m-1forj=2:
3、n-1img_turn=P(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));C(i,j)=sum(img_decrese(:))/(9-d);endend%加高斯噪声的三种情况D=I;%d=0..d=0;fori=2:m-1forj=2:n-1img_turn=Q(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));D
4、(i,j)=sum(img_decrese(:))/(9-d);endendE=I;%d=2d=2;fori=2:m-1forj=2:n-1img_turn=Q(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));E(i,j)=sum(img_decrese(:))/(9-d);endendF=I;%d=4d=4;fori=2:m-1forj=2:n-1img_turn=Q(i-1:i+1,j-1:j+1);img_turn=sort(img_turn
5、(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));F(i,j)=sum(img_decrese(:))/(9-d);endend%加混合噪声的三种情况G=I;%d=0d=0;fori=2:m-1forj=2:n-1img_turn=R(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));G(i,j)=sum(img_decrese(:))/(9-d);endendH=I;%d=2d=2;fori=
6、2:m-1forj=2:n-1..img_turn=R(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));E(i,j)=sum(img_decrese(:))/(9-d);endendJ=I;%d=4d=4;fori=2:m-1forj=2:n-1img_turn=R(i-1:i+1,j-1:j+1);img_turn=sort(img_turn(:));img_decrese=img_turn(floor(d/2)+1:9-floor(d/2));
7、J(i,j)=sum(img_decrese(:))/(9-d);endendfigure;imshow(I);title('原图');figure;imshow(P);title('椒盐噪声图');figure;imshow(Q);title('高斯噪声图');figure;imshow(R);title('混合噪声图');figure;imshow(uint8(A));title('d=0时去椒盐噪声图');figure;imshow(uint8(B));titl