东北大学数字图像处理实验.docx

上传人:b****2 文档编号:17892988 上传时间:2023-08-04 格式:DOCX 页数:33 大小:2.03MB
下载 相关 举报
东北大学数字图像处理实验.docx_第1页
第1页 / 共33页
东北大学数字图像处理实验.docx_第2页
第2页 / 共33页
东北大学数字图像处理实验.docx_第3页
第3页 / 共33页
东北大学数字图像处理实验.docx_第4页
第4页 / 共33页
东北大学数字图像处理实验.docx_第5页
第5页 / 共33页
东北大学数字图像处理实验.docx_第6页
第6页 / 共33页
东北大学数字图像处理实验.docx_第7页
第7页 / 共33页
东北大学数字图像处理实验.docx_第8页
第8页 / 共33页
东北大学数字图像处理实验.docx_第9页
第9页 / 共33页
东北大学数字图像处理实验.docx_第10页
第10页 / 共33页
东北大学数字图像处理实验.docx_第11页
第11页 / 共33页
东北大学数字图像处理实验.docx_第12页
第12页 / 共33页
东北大学数字图像处理实验.docx_第13页
第13页 / 共33页
东北大学数字图像处理实验.docx_第14页
第14页 / 共33页
东北大学数字图像处理实验.docx_第15页
第15页 / 共33页
东北大学数字图像处理实验.docx_第16页
第16页 / 共33页
东北大学数字图像处理实验.docx_第17页
第17页 / 共33页
东北大学数字图像处理实验.docx_第18页
第18页 / 共33页
东北大学数字图像处理实验.docx_第19页
第19页 / 共33页
东北大学数字图像处理实验.docx_第20页
第20页 / 共33页
亲,该文档总共33页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

东北大学数字图像处理实验.docx

《东北大学数字图像处理实验.docx》由会员分享,可在线阅读,更多相关《东北大学数字图像处理实验.docx(33页珍藏版)》请在冰点文库上搜索。

东北大学数字图像处理实验.docx

东北大学数字图像处理实验

数字图像处理

实验一:

了解数字图像处理平台

、实验目的

1)学会使用扫描仪;

2)熟悉MATLAB软件。

、实验内容

1)用扫描仪扫一幅彩色图片;一幅灰度图片。

2)熟悉MATLAB的主界面窗口中各个窗口的功能,利用不同的矩阵输入方式给矩阵赋值,了解MATLAB的简单编程及矩阵基本知识;

3)掌握使用MATLAB的帮助来获得更多的信息。

三、实验仪器设备

扫描仪、计算机和MATLAB应用软件。

、实验目的

1)通过应用MATLAB语言编程实现对图像的处理,进一步熟悉MATLAB软件的编程及应用;

2)通过实验进一步掌握图像处理的基本技术和方法。

、实验内容

1.应用MATLAB§言编写显示一幅灰度图像、二值图像、索引图像及彩色图像

的程序,并进行相互之间的转换;

(1)显示一幅RGBS像:

代码:

I=imread('cs.jpg');

>>imshow(I)

效果:

■-I

I

 

 

(2)RGB专灰度图像

代码:

>>graycs=rgb2gray(l);

>>subplot(1,2,1);

>>subimage(l)>>subplot(1,2,2);

>>subimage(graycs)

效果:

100

200

300

400

100200300400500

100

200

300

400

100200300400500

 

 

(3)RGB专索引图像

代码:

>>[indcs,map]=rgb2ind(I,0.7);

>>subplot(1,2,1)

>>

subimage(l);

>>

subplot(1,2,2);

>>

subimage(indcs,map)

效果:

100

200

300

400

一t

100200300400500

(4)索引图像转RGB

代码:

>>l1=ind2rgb(indcs,map);

>>

subplot(1,2,1);

>>

subimage(indcs,map);

>>

subplot(1,2,2);

>>

subimage(I1);

效果:

100

200

300

400

[的議筹菱汽.'门Q

400500

(5)索引图像转灰度图像:

ss

Bs

oooooo123

ifin

JF

总,,I

"■-c

-&込点

i

X逆;获食

123

In

「一i

>s

 

 

 

代码:

>>i2gcs=ind2gray(indcs,map);

>>subplot(1,2,1);

>>subimage(indcs,map);

>>subplot(1,2,2);

>>subimage(i2gcs,map);

效果:

 

(6)灰度图像转索引图像

代码:

>>[g2ics,map]=gray2ind(graycs,64);

>>subplot(1,2,1);

>>subimage(graycs);

>>subplot(1,2,2);

>>subimage(g2ics,map);

效果:

100

100

200

300

400

I.■■■■--

51;纬或;e

200

300

400

 

 

100200300400500

100200300400500

 

(7)RGB专二值图像

代码:

>>r2bwcs=im2bw(l,0.5);

>>subplot(1,2,1);

>>subimage(I);

>>subplot(1,2,2);

>>subimage(r2bwcs);

效果:

(8)灰度图像转二值图像

代码:

>>g2bwcs=im2bw(graycs,0.5);

>>subplot(1,2,1);

>>subimage(graycs);

>>subplot(1,2,2);

>>subimage(g2bwcs);

效果:

100

200

300

400

100200300400500

100

200

300

400

100200300400500

(9)索引图像转二值图像

代码:

>>i2bwcs=im2bw(indcs,map,0.7);

>>subplot(1,2,1);

>>subimage(indcs,map);

>>subplot(1,2,2);

>>subimage(i2bwcs)

效果:

100

200

300

400

谿i1'

■■*'

=*

I毒呂

A总

400500

100

200

300

400

駅总卞"TT閏子越-J.:

'耳:

:

弋a■盲菩汁笑禺¥丫曲W".■為「:

fI

^hSHeH^BSSeBHI^*;■'tf

100200300400500

2.应用MATLA工具箱演示一幅图像的傅里叶变换、离散余弦变换,观察其频谱

图。

然后将它们进行逆变换,观察逆变换后的图像;

(1)傅里叶变换:

代码:

>>F=fft2(graycs);

 

 

 

>>subplot(1,2,1);

>>subimage(graycs);

>>subplot(1,2,2);

>>subimage(log(abs(F)),[3,10]);

效果:

 

100

(2)傅里叶反变换:

代码:

>>IF=ifft2(F);

>>subplot(1,2,1);

>>subimage(log(abs(F)),[3,10]);

>>subplot(1,2,2);

>>subimage(uint8(IF));

效果:

100

200

300

400

100200300400500

100200300400500

(3)DCT变换:

代码:

>>B=dct2(graycs);

>>subplot(1,2,1);

>>subimage(graycs);

>>subplot(1,2,2);

>>subimage(log(abs(B)),[3,5]);

效果:

100

100

 

200

300

400

V,

200

300

400

 

100200300400500

100200300400500

 

(4)

iDCT变换

 

 

代码:

>>iB=idct2(B);

>>subplot(1,2,1);

>>subimage(log(abs(B)),[3,5]);

>>subplot(1,2,2);

效果:

200

300

400

100

200

300

400

100200300400500

100200300400500

 

 

3.应用MATLA语言编程来实现一幅图像的增强。

(1)取一幅灰度图像,对其进行线性点运算,即

Gbf(Ga)Ga

取(a,P)分别为(1.5,1.2)、(0.7,1.2),对原图像进行线性处理,观察

处理后的结果,并分析直方图的变化。

代码:

>>graycs=double(graycs);

>>graycs1=1.5*graycs+1.2;

>>subplot(2,2,1);

>>subimage(uint8(graycs));

>>subplot(2,2,2);

>>imhist(uint8(graycs));

>>subplot(2,2,3);

>>subimage(uint8(graycs1));

100

200

300

400

200

300

400

100200300400500

3000

2000

1000

▲・H

100

I

200

2

1

100

200

4

x10

0

100200300400500

(2)取一幅灰度图像,对其进行直方图均衡化处理,再对其进行规定化处理,

并对结果进行分析。

思考题:

如果将一幅图像进行一次直方图均衡化处理后,再进行一次直方图均

衡化处理,结果会发生变化吗?

观察两次均衡化的直方图是否一样。

均衡化代码:

>>graycs=uint8(graycs);

>>eqcs=histeq(graycs);

>>subplot(2,2,1);

>>subimage(graycs);

>>subplot(2,2,2);

>>subplot(2,2,3);

>>subimage(eqcs);

>>subplot(2,2,4);

>>imhist(eqcs);

 

 

效果:

200

300

400

100200300400500

100

200

300

400

100200300400500

 

 

 

规定化代码:

>>hgram=50:

2:

250;

>>speciacs=histeq(graycs,hgram);

>>subplot(2,2,1);

>>subimage(graycs);

>>subplot(2,2,2);

>>imhist(graycs);

>>subplot(2,2,3);

200

300

400

100200300400500

100

200

300

400

100200300400500

3000

2000

1000

100

200

 

 

 

思考题:

>>graycs=uint8(graycs);

>>eqcs1=histeq(graycs);

>>eqcs2=histeq(eqcs1);

>>subplot(2,2,1);

>>subimage(eqcs1);

>>subplot(2,2,2);

>>imhist(eqcs1);

>>subplot(2,2,3);

o

o

 

 

 

两次均衡化结果一样。

(3)取一幅灰度图像,加入噪声后对其进行平滑滤波(均值滤波、中值滤波)

并观察不同滤波方式下的效果。

代码;

>>noisecs=imnoise(graycs,'salt&pepper');

>>avecs=filter2(fspecial('average',3),noisecs)/255;

>>medcs=medfilt2(noisecs,[3,3]);

>>subplot(2,2,1);

>>subimage(graycs);

>>title('原图');

>>subimage(noisecs);

>>title('加噪声图'>>subplot(2,2,3);

>>subimage(avecs);

>>title('均值平滑图');

>>subplot(2,2,4);

>>subimage(medcs);

效果:

均值滤波的效果与所使用的领域半径大小有关,半径越大,像素点越多,则

信噪比提高越大,平滑效果越好,但是平滑图像的模糊程度越大。

中值滤波是一种非线性滤波,可以克服整形滤波器所带来的图像细节模糊,

对滤波脉冲干扰及颗粒噪声最为有效。

(4)取一幅灰度图像,采用不同的算子对其进行边缘锐化,并分析结果。

思考题:

为了达到边缘锐化的反差增强效果,实际应用中将高频增强和直方图

均衡化结合起来使用,这两个操作的次序能互换吗?

效果一样吗?

代码:

>>sobelcs=filter2(fspecial('sobel'),graycs);

>>prewittcs=filter2(fspecial('prewitt'),graycs);

>>laplaciancs=filter2(fspecial('laplacian'),graycs);

>>subplot(2,2,1);

>>subimage(graycs);

>>title('原图');

>>subplot(2,2,2);

>>subimage(sobelcs);

>>title('sobel狗');

>>subplot(2,2,3);

>>subimage(prewittcs);

>>title('prewitt狗');

>>subplot(2,2,4);

>>subimage(laplaciancs);

>>title('laplacian狗');

效果:

思考题:

不能次序交换。

因为直方图均衡化是把原始图像的灰度直方图从某个灰

度区间变成在全部灰度范围内的均匀分布,而将高频增强明显的意思是对图像进

行高通滤波,所以如果两个处理次序互换的话会对不同频率成分产生影响,而使

效果不一样,但都可增强反差。

4.对一幅灰度图像进行模糊处理,然后进行逆滤波、维纳滤波与约束最小二乘

方滤波复原实验。

代码:

>>PSF=fspecial('motion',30,45);

>>blurcs=imfilter(graycs,PSF,'circular','conv');

>>subplot(1,2,1);

>>subimage(graycs);

>>titleC原图');

>>subplot(1,2,2);

>>subimage(blurcs);

>>title('运动糊化的图');

效果:

逆滤波代码:

>>wnr1cs=deconvwnr(blurcs,PSF);%逆滤波

>>subplot(1,2,1);

>>subimage(blurcs);

>>subplot(1,2,2);

>>subimage(wnr1cs);

效果:

200

300

400

100200300400500

100

200

300

400

I

I

400500

100200300

 

 

维纳滤波代码:

>>noise=0.1*randn(size(graycs));

>>blumoics=imadd(blurcs,im2uint8(noise));

>>wnr2cs=deconvwnr(blurnoics,PSF);

>>NSR=sum(noise(:

).A2)/sum(im2double(graycs(:

)).A2);

>>wnr3cs=deconvwnr(blurnoics,PSF,NSR);

>>subplot(1,3,1);

>>subimage(blurnoics);

>>title('运动加噪声狗');

>>subplot(1,3,2);

>>subimage(wnr2cs);

>>title('维纳滤波狗');

>>subimage(wnr3cs);

5、应用MATLA语言编写实现一幅图像的旋转、剪切和缩放;

旋转代码:

>>rotatcs=imrotate(graycs,45,'nearest');

>>rotatcs1=imrotate(graycs,45,'bilinear');

>>rotatcs2=imrotate(graycs,45,'bicubic');

>>subplot(2,2,1);

>>subimage(graycs);

>>titleC原狗');

>>subplot(2,2,2);

>>subimage(rotatcs);

>>title('最邻域旋转狗');

>>subplot(2,2,3);

>>subimage(rotatcs1);

>>title('双线性旋转狗');

>>subimage(rotatcs2);

双线性旋转狗

最邻域旋转狗

200

400

600

200400600

200

400

600

200400600

双立方旋转狗

200

400

600

200400600

 

 

 

剪切代码:

>>imshow(graycs);

>>cropcs=imcrop(graycs,[100,100,200,200]);

>>subplot(1,2,1);

>>imshow(graycs);

>>title('原狗');

>>imshow(cropcs);

剪切狗

缩放代码:

>>minimizecs=imresize(graycs,0.2,'nearest');

>>magnifycs=imresize(minimizecs,3,'bilinear');

>>imshow(minimizecs);

>>imshow(magnifycs);

效果:

 

 

6.对一幅图像进行几何失真处理后利用连接点实施图像配准复原。

代码:

>>unrealcs=imrotate(graycs,45,'bilinear');

>>cpselect(unrealcs,graycs);

>>input_points_corr=cpcorr(input_points2,base_points2,unrealcs,graycs);

>>Tlinear=cp2tform(input_points2,base_points2,'linearconformal');

>>subplot(1,3,1);

>>imshow(graycs);

>>subplot(1,3,2);

>>imshow(unrealcs);

>>imshow(imtransform(unrealcs,Tlinear))

 

 

7.应用MATLAB语言编程来实现一幅图像的边缘检测。

代码:

>>csedge=edge(graycs,'canny');

>>subplot(1,2,1);

>>subimage(graycs);

>>subplot(1,2,2);

>>subimage(catedge);

>>imshow(csedge);

效果:

 

100

200

300

400

<)

200

400

600

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2