中值滤波原理及MATLAB实现.

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

MATLAB,MATLAB,,,MATLAB1.2020,60,,60,,,,,,,,,,,,,,,2.,,,,,x,y,,(xy)(xy)2.1m(m)mm(2-2){03407}{00347}35(2-3)(2-4)2.2,matlab1imread()2rgb2gray()3imnoise()4medfilt2(),matlabMATLABclc;clearall;closeall;img=imread('3_1.bmp');img_0=rgb2gray(img);img_1=imnoise(img_0,'salt&pepper',0.02);img_2=medfilt2(img_1);subplot(2,2,1);imshow(img);title('');subplot(2,2,2);imshow(img_0);title('');subplot(2,2,3);imshow(img_1);title('');subplot(2,2,4);imshow(img_2);title('');MatLab%x,n(nn)functiond=avefilt(x,n)a(1:n,1:n)=1;%an,1p=size(x);%p,pn,qnx1=double(x);x2=x1;%A(a:b,c:d)Aab,cdfori=1:p(1)-n+1forj=1:p(2)-n+1c=x1(i:i+(n-1),j:j+(n-1)).*a;%x1(i,j)nns=sum(sum(c));%c()x2(i+(n-1)/2,j+(n-1)/2)=s/(n*n);%endend%d=uint8(x2);%x,n(nn)functiond=midfilt(x,n)p=size(x);%p,pn,qnx1=double(x);x2=x1;fori=1:p(1)-n+1forj=1:p(2)-n+1c=x1(i:i+(n-1),j:j+(n-1));%x1(i,j)nn,(n)e=c(1,:);%cforu=2:ne=[e,c(u,:)];%cendmm=median(e);%mmx2(i+(n-1)/2,j+(n-1)/2)=mm;%endend%d=uint8(x2);%Snkfunctiond=gaussfilt(k,n,s)Img=double(s);n1=floor((n+1)/2);%fori=1:nforj=1:nb(i,j)=exp(-((i-n1)^2+(j-n1)^2)/(4*k))/(4*pi*k);endend%bImg1=conv2(Img,b,'same');%d=uint8(Img1);%try%h=imread('photo.jpg');%c=rgb2gray(h);%256figure,imshow(c),title('');%g=imnoise(c,'gaussian',0.1,0.002);%figure,imshow(g),title('');%%n=input('\n');A=fspecial('average',n);%3X3Y=filter2(A,g)/255;%,figure,imshow(Y),title('');%%:Y2=avefilt(g,n);%nfigure,imshow(Y2),title('');%%:Matlabn2=input('\n');Y3=medfilt2(g,[n2n2]);%n2figure,imshow(Y3),title('Matlab');%%:Y4=midfilt(g,n2);%figure,imshow(Y4),title('');%:matlabn3=input('\n');k=input('\n');A2=fspecial('gaussian',k,n3);%Y5=filter2(A2,g)/255;%figure,imshow(Y5),title('Matlab');%%:Y6=gaussfilt(n3,k,g);%n3kfigure,imshow(Y6),title('');%catch%disp(lasterr);%end\*[thr,sorh,keepapp]=ddencmp('den','wv',x);x1=wdencmp('gbl',J1,'sym4',2,thr,sorh,keepapp);%x%x1*/3.,,matlab,,,,[1]..,2007[2],.2003(2)[3],.2009(12)[4],.matlab2009(12)[5].MATLAB6.5.,2005

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功