# Matlab 图像处理实验

luoxinwu123 分享于 2011-08-01

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.

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);

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.

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

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.

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).

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('陷波滤波后图像');

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

×
• 登录
• 注册

×