ITKeyword,专注技术干货聚合推荐

注册 | 登录

Matlab 图像处理实验

luoxinwu123 分享于 2011-08-01

推荐:Matlab图像处理小结

转自:http://blog.sina.com.cn/s/blog_6163bdeb0102e5q7.html 经常做做图像处理的东西,时间长了,有些函数就忘了,看到网上有人总结,收藏了。 1. 图像和图像

2020腾讯云8月秒杀活动,优惠非常大!(领取2860元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1040

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
地址https://www.aliyun.com/minisite/goods

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

 

 

结果:

推荐:MATLAB中图像处理的函数

MATLAB 图像处理命令  MATLAB中图像处理的一些简单函数 A、 imread imread函数用于读入各种图像文件,其一般的用法为 [X,MAP]=imread(‘filename’,‘fmt’)其

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

相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。