利用matlab处理图片实验,Matlab 图像处理实验

Project0501

Noise Generators

This is a generic project, in the sense that the programs developed here are used in

several of the projects that follow.  See Fig. 5.2 for the shapes and parameters of the

following noise probability density functions.

(a) Find (or develop) a program to add Gaussian noise to an image.  You must be

able to specify the noise mean and variance.

(b) Find (or develop) a program to add salt-and-pepper (impulse) noise to an

image. You must be able to specify the probabilities of each of the two noise

components.

程序:

I=imread('F:\images05\Fig5.03.jpg');

subplot(2,2,1),imshow(I);

gtext('原始图像');

J1=imnoise(I,'gaussian',0.2);

subplot(2,2,2),imshow(J1);

gtext('加高斯噪声');

J2=imnoise(I,'poisson');

subplot(2,2,3),imshow(J2);

gtext('加泊松噪声');

J3=imnoise(I,'salt & pepper',0.2);

subplot(2,2,4),imshow(J3);

gtext('加脉冲噪声');

I=double(I);

J1=double(J1);

J2=double(J2);

J3=double(J3);

[m,n]=size(I);

s=0;

s1=0;

s2=0;

s3=0;

for i=1:m

for j=1:n

s=I(i,j)+s;

s1=J1(i,j)+s1;

s2=J2(i,j)+s2;

s3=J3(i,j)+s3;

end

end

mean=s/(m*n);

mean1=s1/(m*n);

mean2=s2/(m*n);

mean3=s3/(m*n);

加噪结果:

平均值:

原始图像:mean =87.0864

加高斯噪声图像:mean1 =132.3158

加泊松噪声图像:mean2 =87.0719

加脉冲噪声图像:mean3 =95.0095

Project0502

Noise Reduction Using a Median Filter

(a) Modify the program that you developed in Project 03一04 to perform 3 x 3 median filtering.

(b) Download Fig. 5.7(a) and add salt-and-pepper noise to it, with Pa=Pb=0.2

(c) Apply medianfiltering to the image in (b).  Explain the major differences

between your result and Fig.5.10(b).

程序:

I=imread('F:\images05\Fig5.03.jpg');

J=imnoise(I,'salt & pepper',0.2);

h=1/9*ones(3,3);

K=conv2(J,h,'same');

H=medfilt2(J);

subplot(2,2,1),imshow(I);

gtext('原始图像');

subplot(2,2,2),imshow(J);

gtext('加噪图像');

subplot(2,2,3),imshow(K,[]);

gtext('算术均值滤波后的图像');

subplot(2,2,4),imshow(H);

gtext('中值滤波后的图像');

结果:

Project0503

Periodic Noise Reduction Using a Notch Filter

(a) Write a program that implements sinusoidal noise of the form given in Problem

5.14. The inputs to the program must be the amplitude, A, and the two frequency

components u0 and v0 shown in the problem equation.

(b) Download image 5.26(a) and add sinusoidal noise to it, with u0=M/2 (the

image is square) and v0=0.  The value of A must be high enough for the noise to

be quite visible in the image.

(c) Compute and display the spectrum of the image.  If the FFT program you

developed in Project 4.01 can only handle images of size equal to an integer power

of 2, reduce the size of the image to 512 x 512 or 256 x 256 using the program

from Project 02-04.  Resize the image before adding noise to it.

(d) Notch-filter the image using a notch filter of the form shown in Fig. 5.19(c).

程序:

I=imread('F:\images05\Fig5.03.jpg');

subplot(2,2,1),imshow(I);

gtext('原始图像');

J=imnoise(I,'salt & pepper',0.2);

subplot(2,2,2),imshow(J);

gtext('加噪图像');

J=double(J);

K=fft2(J);

[M,N]=size(J);

[H,D]=dpfilter('gaussian',M,N,1000,1,0,0);

A=H.*K;

B=ifft2(A);

B=real(B);

[H,D]=dpfilter('gaussian',M,N,5000,1,0,0);

C=H.*K;

P=real(ifft2(C));

subplot(2,2,3),imshow(B,[]);

gtext('陷波滤波后图像');

subplot(2,2,4),imshow(P,[]);

gtext('陷波滤波后图像');

结果:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值