欢迎来到天天文库
浏览记录
ID:14155335
大小:45.00 KB
页数:4页
时间:2018-07-26
《领域平均与中值滤波》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验邻域平均法和中值滤波代码邻域平均法functiond=uniform(x,n,a)p=size(x);x1=double(x);x2=x1;m=a;w=(n+1)/2;fori=w:p(1)-wforj=w:p(2)-wc=x1(i-w+1:i+w-1,j-w+1:j++w-1);e=c.*m;e1=0;forkw=1:nforkh=1:n4e1=e1+e(kw,kh);end;end;x2(i+w-1,j+w-1)=e1;endend中值滤波functiond=midfilt(x,n)p=size(x);x1=double(x);
2、x2=x1;fori=1:p(1)-n+1forj=1:p(2)-n+1c=x1(i:i+(n-1),j:j+(n-1));4e=c(1,:);foru=2:ne=[e,c(u,:)];endmm=median(e);x2(i+(n-1)/2,j+(n-1)/2)=mm;endend实现clc;clear;n=9;a=1/25*[1111111114111111111111111111111111111111111111111111111111111111111111111111111111];h=imread('xm256×256
3、LENA256_2.bmp');subplot(2,2,1);imshow(h);h1=uniform(h,n,a);subplot(2,2,2);imshow(h1);h2=midfilt(h,n);subplot(2,2,3);imshow(h2);4
此文档下载收益归作者所有