机器视觉实验报告_第1页
机器视觉实验报告_第2页
机器视觉实验报告_第3页
机器视觉实验报告_第4页
机器视觉实验报告_第5页
已阅读5页,还剩30页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验报告

课程名称:机器视觉与图像处理

班级:自动F1202

姓名:

学号:

实验时间:2015.2.23

实娶

实验名称

Matlab软件的使用

实验内容

打开MATLAB软件,了解菜单栏、工具栏、状态栏、命令窗口等;

了解帮助文档help中演示内容demo有哪些;

找到工具箱类里面的ImageProcessing工具箱,并进行初步学习,为后续实验做准备。

实验原理:

通过matlab工具箱來进行图像处理

实验步骤

双击桌面上的matlab图标,打开matlab软件

了解菜单栏、工具栏、状态栏、命令窗口等

如下图1-1所示

FileEditDebugParallelDesktopWindowHelp

:tJ已|•引0IkE0国|@|CurrentFolder:D:\matlab\anzhuang\bin▼jQ111

Shortcuts封HowtoAdd上What'sNew

CurrentFolder

CommandWindow

.D:►motlab►anzhuang►bin►

S

m2iregistry

E

registry

B

util

S

Win32

DName

£actxlicensem程]ctrlts.mQctrltsl.m圈deploytcol.bat

£insttype.inijordants.m,,IcdatajcmlIA]Icdata.xsd

MATLABdesktopkeyboardsiInaddition^iranykevboarcacrossthedesktop・

Tocustoirizckeyboardshojrestorepreviousdefault<

Clickh亡reifyoudonot?

Details

Selectafiletoviewdetails

图1"1

7解帮助文档help中演示内容demo有哪些;步骤如下图1-2

2MATU87.1U)(IWlOb)

ReEditOebugP«r«MD«Uc2op\A6ndow|Hdp

Shortoxs£1HowtoAdd<WhatsNew

SertMdtf

ProductMdp

FunctionBrowser

Us«n9theDtsktopUting、Command

Same-

2«9^try

WebR«©urc«

GetProductTKek

CheckforUpdates

ishortcuti,suchasCtrl*S.arenowcustoflaizable・»:ardshortcutshavechangedforisprovedconsistency

©•ttdicemejn

©ctriulxn•VgoyZZtdimttype*勺jordiMvmkd«UJvni血kdMJisd

Lkeming

D*mot

TermsofUw

Patents

AboutMATUS

ihortcuts.usePr小rtnc".Fromthere,youcmalso»ItsettingsbyfollowingthestepsoutlinedinHelp.

>twanttoseethisoe$meagoin.

图1-2

打开help内容demo后,里面的工具箱如图所示。

Contents

SearchResults

❾Help

FileEditViewGoFavoritesDesktopWindowHelp

Search

©◎MATLAB

j申bGettingStarted

I#9User'sGuide

::

IAFunctions

申“◎BioinformaticsToolbox+iCommunicationsToolbox申◎ControlSystemToolbox卧◎CurveFittingToolbox®DataAcquisitionToolbox卧◎DatabaseToolbox回◎DatafeedToolbox宙窃EconometricsToolbox*◎EmbeddedMATLAB毎◎FilterDesignToolboxf◎FilterDesignHDLCoder由窃FinancialToolboxfQFinancialDerivativesToolbox国QFixed-IncomeToolboxt◎Fixed-PointToolbox国◎FuzzyLogicToolbox

±◎GlobalOptimizationToolbox回◎ImageAcquisitionToolbox

ProcessingToolbox

p◎MappingToolbox

毎©MATLABBuilderEX

MATLABBuilderJA

4-^MATLABBuilderNE

@◎MATLABCompiler

申®MATLABDistributedComputingServer

图1-3

找到工具箱类里面的LnageProcessing工具箱,并进行初步学习,为后续实验做准备。找到并打开UllagePiocessmg2E具箱,窗口如图1・4,图1・5所示

审“0FinancialToolbox

书“母^FinancialDerivativesToolbox

Fixed-IncomeToolbox

4)-^Fixed-PointToolbox

®FuzzyLogicToolbox

◎GlobalOptimizationToolbox

由◎ImageAcquisitionToolbox

费ImageProcessingToolbox

申◎InstrumentControlToolbox

◎MappingToolbox

®◎MATLABBuilderEX

@®MATLABBuilderJA

申易MATLABBuilderNE

MATLABCompiler

MATLABDistributedComputingServer

图1-4

I

M>M/WIWWA

S)❷GlobalOptimizationToolboxctQImageAcquisitionToolbox

ImageProcessingToolbox

囹►GettingStarted£•0UserfsGuide圧fxFunctions

■ExamplesDvDemos

t)Deblurring±]EnhancementtJImageRegistration®ImageSegmentation♦SpatialTransformationSMeasuringImageFeatures®TransformstjWorkingwithlargeData匡dReleaseNotes

♦QInstrumentControlToolbox?◊MaooinaToolbox

图1-5

五•实验总结和分析

通过实验前的理论准备和老师的讲解,对matlab有了一定认识,在实验中,

了解了实际操作中的步骤以及matlab中的图像处理工具箱及其功能,为后续的学习打下了基础,并把理论与实际相结合,更加深入的理解图像处理。

实验二

实验名称

图像的增强技术

实验内容

了解图像增强技术/方法的原理;

利用matlab软件,以某一用途为例,实现图像的增强;

通过程序的调试,初步了解图像处理命令的使用方法。

实验原理:

通过matlab工具箱來进行图像处理,通过输入MATLAB可以识别的语言命令來让MATLAB执行命令,实现图像的增强。

四•实验步骤及结果

双击MATLAB图标打开MATLAB软件;

单击help/Demos打开帮助中的演示;

找到bnageProcessing工具箱中的图像增强,如图2-1所示

ImageProcessingToolbox

}审七GettingStarted

j备QUser'sGuide

=(S-AFunctions

::

}iExamples

IwDemos

jS)Deblurring

nhancement

HContrastEnhancementTechniques

!

h-CorrectingNonuniformIllumination

L-EnhancingMultispectralColorCompositeImages

图2-1

4•点击ContrastEnhancementTechniques和ContrastEnhancementTechniques即对比度增强技术,结果如图2-1所示

ContrastEnhancementTechniques

TheImageProcessingToolbox™containsseveralimageenhancementroutines・

Threefunctionsareparticularlysuitableforcontrastenhancement:

imadjushisteq,andadapthisteq・Thisdemocomparestheiruseforenhancinggrayscaleandtruecolorimages・

Contents

Step1:LoadInisges

Step2:ResizeIiwes

Step3:EnhanceGroysceleImages

Step4:EnhanceColorIinasges

Step1:LoadImages

Readintwograyscaleimages:pout・tifandtire・tif・AlsoreadinanindexedRGBimage:shadow・tif.

pout=imreadCpout・tiF);

tire=imreadC"tire・tiF);

[Xmap]=imreadCsh&dcw.tiF);

shadow二ind2rgb(X,map);%converttotruecolor

图2-2

图中有4个步骤,然后按照这四个步骤一步一步的进行即可得到理想的图像。

Step1:LoadImages:阅读两种灰度图像:pout,tif和tire,tiffo同时读取索引RGB图像:shadow,tifo程序如下:pout=imread(1pout・tif');

tire=imread(1tire・tif1);

[Xmap]=imread(1shadow

shadow=ind2rgb(X,map);%converttotruecolor

Step2:ResizeImages:为了使图像比较容易,调整大小的图像,以具有相同的宽度。通过缩放的高度保存其长宽比。

Step3:EnhanceGrayscaleImages使用默认设置,比较以下三种方法的效果:*imadjust增加图像的通过映射的输入强度图像的值,以使得,在默认情况下,数据的1%是饱和的,在输入数据的低和高强度的新值的对比度。*histeq进行直方图均衡化。它增强图像的由在强度图像变换的值,使得输出图像的直方图大致指定直方图(均匀分布默认)匹配对比度。*adapthisteq执行对比度限制的自适应直方图均衡。不像histeq,它作用于小数据区(瓦),而不是整个图像。每个瓦片的对比度被增强,使得每个输出区的直方图大致指定直方图(均匀分布默认情况下)相匹配。对比度增强可以以避免扩增这可能是存在于图像中的噪声的限制。

pout_imadjust=imadjust(pout);pout_histeq=histeq(pout);

图2-

pout_adapthisteq=adapthisteq(pout);imshow(pout);

title(1Original1);

figure,imshow(pout_imadjust);

title(1Imadjust');

结果如图2-3所示

FieE&tViev/InsertToolsDesktopWindowHelp鼻

□dd氏丸\的®电尤▼氓□

Imadjust

图2-3figure,imshow(pout_histeq);

title(1Histeq1);

figure,imshow(pout_adapthisteq);

title(1Adapthisteq1);结果如图2_4所不

□ddJ

•、二厂©kH・

C3@

■Figure3

FileEditViewInsertToolsDesktopWindowHdp

B8Figure4

FileEditViewInsertToolsDesktopWindowHelp・PUd2Q\少S)7"•0□”

Kisteq

Adipthi$t«q

图2-

输入以下程序得到如图2-5所示的

tire_imadjust=imadjust(tire);

tire_histeq=histeq(tire);

tire_adapthisteq=adapthisteq(tire);

figure,imshow(tire);

title(1Original1);

figure,imshow(tire_imadjust);title(1Imadjust');

图2-5

输入以下程序得到如图2-6所示的:figure,imshow(tire_histeq);title('Histeq');

BlFigure7

o回23

FileEditViewInsertToolsDesktopWindcv/Help乞

'□ddb22曹®親虜>

a□"

figure,imshow(tire_adapthisteq);title(1Adapthisteq');

FileEditViewInsertToolsDesktopWindowHelp、

Histeq

Adapthisteq

Step4:EnhanceColorImages:srgb21ab=makecform(1srgb21ab1);lab2srgb=makecform(1lab2srgb1);

shadow_lab=applycform(shadow,srgb21ab);%converttoL*a*b*

%thevaluesofluminositycanspanarangefrom0to100;scalethem%to[01]range(appropriateforMATLAB(R)intensityimagesofclassdouble)%beforeapplyingthethreecontrastenhancementtechniquesmax_luminosity=100;

L=shadow_lab(:,:z1)/max_luminosity;

%replacetheluminositylayerwiththeprocesseddataandthenconvert*theimagebacktotheRGBcolorspaceshadow_imadjust=shadow_lab;

shadow_imadjust(:,:,1)=imadjust(L)*max_luminosity;

shadow_imadjust=applycform(shadow_imadjustflab2srgb);

shadow_histeq=shadow_lab;

shadow_histeq(:z:F1)=histeq(L)*max_luminosity;

shadow_histeq=applycform(shadow_histeq,lab2srgb);

shadow_adapthisteq=shadow_lab;

shadow_adapthisteq(:fz1)=adapthisteq(L)*max_luminosity;shadow_adapthisteq=applycform(shadow_adapthisteq,lab2srgb);

figure,imshow(shadow);title(1Original1);

figure,imshow(shadow_imadjust);title(1Imadjust1);

结果如图5-7所示

图5-7

figure,imshow(shadow_histeq);title(1Histeq1);

figure,imshow(shadow_adapthisteq);t(1Adapthisteq1);

结果如图5-8所示

WFigure14

QFigure13

FileEditViewInsertToolsDesktopWindowHdp・

Adapthisttq

0

>w、

0

FileEditViewInsertToolsDesktopWindowHelp

k\\c©x•g□

图5-8

五•实验总结和分析

对比度增强技术:图像处理工具箱”包含了多种图像增强程序。三种功能特别适合用于对比度增强:imadjust,histeq和adapthisteq。这个演示比较了它们的使用增强灰度和真彩色图像。

通过这儿个程序输入的执行结果比较我们就可以看出哪一个方法的增强效

果是我们所需要的,当然我们也可以根据自己的需要來选择哪一种方法。

图3-1

实验三

实验名称

图像特征提取

实验内容

了解图像特征提取的方法;

利用matlab软件,编程实现图像中长度、角度、半径、边界等特征的提取测量;

通过程序的调试,初步了解图像特征提取命令的使用方法。

实验原理:

通过matlab工具箱來进行图像处理,通过输入MATLAB可以识别的语言命令

來让MATLAB执行命令,实现图像特征提取。

实验步骤及结果

双击MATLAB图标打开MATLAB软件;

单击help/Demos打开帮助中的演示;

找到bnageProcessing匸具箱中的图像特征提取,如图3-1所示

丁-'J*出2旳昨5jy肌

曰©ImageProcessingToolbox

◎bGettingStarted

由©User'sGuide

\3AFunctions

••

0•

?■'.Examples

Q-<Demos

|®Deblurring

=®Enhancement

!!:

I£)ImageRegistration

!!I

jE-ImageSegmentation

+1SpatialTransformation

MeasuringImageFeatures

F*FirdingtheLengthofaPenduluminMotion

HGranulometryofSnowflakes

••••

hIdentifyingRoundObjects

在图像特征提取的卜面有:

找到一个摆在运动的长度

雪花的粒度

识别圆形物体

识别圆形的物体

在灰度图像测屋区域

测量带卷的半径

六个应用实例,本次实验选取一个:测量带卷的半径。进行试验。

我们的目标是测量辘的带,这是部分地由磁带分配器遮蔽的半径。将利用bwliaceboundary来完成这个任务。

分为五个步骤:

*步骤1:阅读图像

RGB=imread(1tape.png,);

imshow(RGB);

text(15z15/fEstimateradiusoftherolloftape1r・・

QFigg1,壬

FileEditViewInsertToolsDesktopWindowHelp

卜缺处彰⑥渥匡1■口

Estimateradiusoftherolloftape

1FontWeight1.1bold1,1Color;y')

>hadow_adapthisteq=shadov/.lab;ihadow_ddapthisteq(:r:rl)=adapthisteq(L)*m;hadow_adapthisteq=applycform(shadow_a:igurefimshow(shadov/);titleCOriginal1);

^gure,imshow(shadovcimadjust);

LitleCImadjust')

>>figure,imshow(shadow_histeq];rirleCHisteq);

:igurefimshow(shadov/_adapthisteq);

titleCAdapthisteq1)

>>RGB=imreadCtape.png1);mshow(RGB);

text(15r15ZEstimateradiusoftherolloftape*

TontWeighTVboldVColoCy)

>>

图3-2

水步骤2:阈值图像

I=rgb2gray(RGB);threshold=graythresh(I);

BW=im2bw(I/threshold);imshow(BW)

图3-3

*步骤3:提取初始边界点位置

dim=size(BW);

col=round(dim(2)/2)-90;

row=find(BW(:zcol)r1);

col=round(dim(2)/2)-90;

row=find(BW(:fcol)r1)

row=

133

图3-4

*步骤4:跟踪的边界

connectivity=8;

num_points=180;

contour=bwtraceboundary(BW,[row,col],1N',connectivityznum_points);

imshow(RGB);

holdon;

plot(contour(:f2)zcontour(:z1)z1g1,1Linewidth\2);

FileEditViewInsertToolsDesktopWindowHelp

图3-5

*步骤5:适合圆的边界

x=contour(:,2);

y=contour(:,1);

%solveforparametersa,b,andcintheleast一squaressenseby%usingthebackslashoperator

abc=[xyones(length(x),l)]\一(x•八2+y・A2);

a=abc(1);b=abc(2);c=abc(3);

%calculatethelocationofthecente工andtheradius

xc=-a/2;

yc=-b/2;

radius=sqrt((xc^Z+yc八2)-c)

%displaythecalculatedcenter

plot(xc,yc,1yx1z'LineWidth1z2);

%plottheentirecircle

theta=0:0.01:2*pi;

%useparametricrepresentationofthecircletoobtaincoordinates%ofpointsonthecircle

Xfit=radius*cos(theta)+xc;

Yfit=radius*sin(theta)+yc;

plot(Xfit*Yfit);

message=sprintf('Theestimatedradiusis%2・3fpixels1rradius);text(15,15,message,1Color1f1y1z1FontWeight1r,bold,);

图3-6

实验总结和分析

图像处理工具箱”软件提供了一套全面的参考标准算法和图像处理,分析,可视化和算法开发的图形化工具。您可以恢复干扰或退化图像,增强图像清晰度提高,提取特征,分析形状和纹理,并注册两个图像。大多数工具箱函数都写在公开MATLAB®语言,让你可以检查算法,修改源代码,并创建自己的自定义功能的能力。

实验四

实验名称

图像变换

实验内容

了解图像变换的原理;

利用matlab软件,编程实现投影数据的图像重构;

通过程序的调试,初步了解图像投影变换的应用。

实验原理:

通过matlab工具箱來进行图像处理,通过输入MATLAB可以识别的语言命令來让MATLAB执行命令,实现图像变换。

四•实验步骤及结果

双击MATLAB图标打开MATLAB软件;

单击help/Demos打开帮助中的演示;

找到bnagePiocessing匸具箱中的图像特征提取,如图4-1所示:

ImageAcquisitionloolbox自ImageProcessingToolbox由》GettingStarted由©UseHsGuide

!!

SAFunctions

qExamples白・、Demos

••

!Deblurring

j(SEnhancement

j由ImageRegistration

••

®-ImageSegmentation

i(^-SpatialTransformation

S-MeasuringImageFeatures

!:

QTransforms

^ReconstructinganImagefromProjectionData

©WorkingwithLargeData田二jReleaseNotes

图4-1

图像变换的内容:*创建头幻影

*平行梁-计算综合预测

*平行光束-从投影数据重建头部模型

*扇形波束-计算合成预测

*扇形波束-从投影数据重建头部模型

①创建头幻影:

P=phantom(256);

imshow(P)

结果如图4-2所示

*平行梁-计算综合预测

thetal=0:10:170;

[Rlzxp]=radon(P,thetal);num_angles_Rl=size(R1r2)

图4・2

结果如图4・3

90

»-thetal二0:10:170;

[Rljxp]二radon(P_,thetal);

num_angles_Rl二size(Rl^2)

num_angles_Rl

18

图4-3

theta2=0:5:175;

[R2,xp]=radon(P,theta2);

num_angles_R2=size(R2、2)

»theta2二0:5:175;

[R2jxp]二radon(P_,theta2);

num_angles_R2二size(R2j2)

num_angles_R2二

36

图4-4

theta3=0:2:178;

[R3Zxp]=radon(P,theta3);

num_angles_R3=size(R3,2)

»theta3=0:2:178;

[R3‘xp]=radon(P,theta3);

nuin_angles_R3二size(R3,2)

nuin_angles_R3二

图4-5

N_R1=size(R1r1)

N_R2=size(R2f1)

NR3=size(R3,1)

»N_R1二size(Ria)

N_R2=size(R25l)

N_R3=size(R32l)

N_R]=

M_R2二

N_R3二

367

图4-6

P_128=phantom(128);

[R_128zxp_128]=radon(P_128,thetal);

N_128=size(R_128,1)

??尸_丄乞塔二phantoml丄25丿;

[R_128,xp_128]二radon(P_l28,thetai)N_128二size(R_12&1)-

N_128二

185

图4-7

figure,imagesc(theta3,xp,R3)

colormap(hot)

colorbar

xlabel(!ParallelRotationAngle一\theta(degrees)1);ylabel(!ParallelSensorPosition一x\prime(pixels)1);

0

ParallelRotationAnqle・6(decrees}

FileEditViewInsertToolsDesktopWindowHelp

图4-8

5

40

3

10

(s-ax-d)X-uo匸一⑷od」OSU3S-3-2£

□決头的®累X*魁I[□匡II■

oo

5o

00o5

1-

020406080100120140160

20

*平行光束-从投影数据重建头部模型:

output_size=max(size(P));

dthetal=thetal(2)-thetal(1);

Il=iradon(R1rdthetal,output_size);figure,imshow(II)

图4-9

dtheta2=theta2(2)一theta2(1);

=iradon(R2rdtheta2zoutput_size);figure,imshow(12)

图4-10

dtheta3=theta3(2)-theta3(1);

=iradon(R3,dtheta3zoutput_size);figure,imshow(13)

BJFigure5

FileEdit

「u:If回]E2I

ViewInsertTo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论