|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
- function [outimage]=jzzz(array); %文件名为jzzz的极值中值滤波程序
- array=imread('flowers.tif');
- array=imnoise(array,’gaussian’,0,0.005)
- [X,Y]=size(array);
- hb(1:256)=0;
- for x=1:X
- for y=1:Y
- g=double(array(x,y))+1;
- hb(g)=hb(g)+1;
- end
- end %对矩阵中间元素进行处理
- for x=2:(X-1)
- for y=2:(Y-1)
- %定义一个数组存放3*3数值
- a(1:9)=0;
- i=1;
- for m=(x-1):(x+1)
- for n=(y-1):(y+1)
- a(i)=double(array(m,n));
- i=i+1;
- end
- end
- s=a; %对数组a进行按从大到小排列
- for i=1:8
- for j=1:9-i
- if s(j)>s(j+1)
- t=s(j);
- s(j)=s(j+1);
- s(j+1)=t;
- end
- end
- end
- if a(5)==s(9)|a(5)==s(1)
- outimage(x,y)=uint8(s(5));
- else outimage(x,y)=uint8(a(5));
- end
- end
- end
- [X1,Y1]=size(outimage);
- he(1:256)=0;
- for x=1:X1
- for y=1:Y1
- g=double(outimage(x,y))+1;
- he(g)=he(g)+1;
- end
- end
- figure,imshow(array);title;
- figure,imshow(outimage);title;
复制代码 |
|