好文档 - 专业文书写作范文服务资料分享网站

均值滤波matlab程序代码

天下 分享 时间: 加入收藏 我要投稿 点赞

.

%均值滤波

%方法一:filter2 clear all;

figure

I=rgb2gray(imread('132.jpg'));

I=imnoise(I,'salt & pepper',0.1); %加入椒盐噪声

K1=filter2(fspecial('average',3),I)/255; %进行3*3均值滤波 K2=filter2(fspecial('average',5),I)/255; %进行5*5均值滤波 K3=filter2(fspecial('average',7),I)/255; %进行7*7均值滤波 subplot(2,2,1),imshow(I),title('椒盐噪声图'); %显示原图像 subplot(2,2,2),imshow(K1),title('3*3均值滤波图像'); subplot(2,2,3),imshow(K2),title('5*5均值滤波图像'); subplot(2,2,4),imshow(K3),title('7*7均值滤波图像');

%方法二 双循环语句,移动平均法 %均值滤波 clc,clear; figure

f=rgb2gray(imread('132.jpg'));

subplot(2,2,1),imshow(f),title('原图'); f1=imnoise(f,'gaussian',0.002,0.0008);

subplot(2,2,2),imshow(f1),title('高斯噪声图'); k1=floor(3/2)+1; k2=floor(3/2)+1; X=f1;

[M,N]=size(X);

uint8 Y=zeros(M,N); funBox=zeros(3,3); for i=1:M-3

for j=1:N-3

funBox=X(i:i+3,j:j+3); s=sum(funBox(:));

精品

.

h=s/16;

Y(i+k1,j+k2)=h; end; end;

Y=Y/255;

subplot(2,2,3),imshow(Y),title('均值滤波图');

如有侵权请联系告知删除,感谢你们的配合!

精品

均值滤波matlab程序代码

.%均值滤波%方法一:filter2clearall;figureI=rgb2gray(imread('132.jpg'));I=imnoise(I,'salt&pepper',0.1);%加入椒盐噪声K1=filter2(fspecial('average',3),I)/255
推荐度:
点击下载文档文档为doc格式
44kl55rtvp7yogl1itk20zdc523xwm00i4x
领取福利

微信扫码领取福利

微信扫码分享