matlab与数字图像处理_第1页
matlab与数字图像处理_第2页
matlab与数字图像处理_第3页
matlab与数字图像处理_第4页
matlab与数字图像处理_第5页
已阅读5页,还剩43页未读, 继续免费阅读

下载本文档

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

文档简介

MatlabwithDIP教学,TheMATLABImageProcessingToolbox,TheImageProcessingToolboxisacollectionofMATLABfunctions(calledM-functionsorM-files)thatextendthecapabilityoftheMATLABenvironmentforthesolutionofdigitalimageprocessingproblems.,TheMATLABImageProcessingToolbox(cont.),Including:-Spatialimagetransformations-Morphologicaloperations-Neighborhoodandblockoperations-Linearfilteringandfilterdesign-Transforms-Imageanalysisandenhancement-Imageregistration-Deblurring-Regionofinterestoperations,HowdoIknowM-function?,FinditinMatlabHelp.-bycategory.-byalphabeticalorder.Finditonthetextbook.,Matlab内建图像,C:MATLAB7toolboximagesimdemos皆为MatlabHelp中范例的原始图像。使用时只需直接在指令中输入文件名,即可使用。适用于观察影像处理结果,DifferentImageTypes,IndexedimagesIntensity(grayscale)imagesBinaryimagesRGB(true-color)images,Readinganimage,imread()功用:将图像加载并存成array格式备用用法:I,map=imread(filename);I=imread(filename);ex:I=imread(pout.tif);I为指向影像的变量不指定变数,则为ans,Displayinganimage,imshow()功用:开启一个窗口显示影像用法:imshow(I)imshow(I,map)Figure,imshow()功用:开启一个新窗口显示影像用法:figure,imshow(I),Displayinganimage(cont.),imshow(I,low,high)imshow(I,)功用:displaysIasagrayscaleintensityimage,specifyingthedatarangeforI.TheminimumvalueinIisdisplayedasblack,andthemaximumvalueisdisplayedaswhite.,Displayinganimage(cont.),Spatialdomain,Displayinganimage(cont.),pixval:功能:cursoronimagetoshowpixelvalues用法:imshow(I),pixval,Displayinganimage(cont.),colorbar功能:Todisplayanimagewithacolorbarthatindicatestherangeofintensityvalues.用法:imshow(I),colorbarex:I=imread(pout.tif);imshow(I),colorbar,Writinganimage,imwrite()功能:将影像写入成档案用法:imwrite(I,filename,format)ex:imwrite(I,pout.jpg,JPEG);,Imageinformation,Imagesize:size()ex:I=imread(saturn.png);size(I)M,N=size(I)M=影像I的高N=影像I的宽,Imageinformation,whos功用:displayinformationaboutanimage.ex:whosIImfinfo(filename)功用:displayinformationaboutimagefile.ex:info=imfinfo(saturn.png),DigitalImageprocessing,图像二值化g=im2bw(I,T);功用:ConvertintensityimageItobinaryimagegusingthresholdT,whereTmustbeinrange0,1.ex:I=imread(pout.tif);g=im2bw(I,0.4);imshow(g),colorbar,DigitalImageprocessing(cont.),彩色转灰阶Rgb2gray()功用:将RBG彩色影像转换成gray-level影像。ex:I=imread(saturn.png);g=rgb2gray(I);imshow(g),colorbar,DigitalImageprocessing(cont.),反相imcomplement()功用:Thenegativeofanimage.ex:J=imcomplement(g);imshow(J),DigitalImageprocessing(cont.),变更影像大小imresize(I,scale,method);功用:TerpolationMethod:-nearest:Nearest-neighborinterpolation-bilinear:Bilinear(thedefault)-bicubic:Bicubicinterpolation,DigitalImageprocessing(cont.),ex:I=imread(circuit.tif);J=imresize(I,1.25);imshow(I)figure,imshow(J)ex:I=imread(circuit.tif);J=imresize(I,100150,bilinear);imshow(I)figure,imshow(J),DigitalImageprocessing(cont.),旋转影像imrotate(I,angle);功用:Torotateanimage.ex:I=imread(pout.tif);J=imrotate(I,35);imshow(J),MoreExample,Usingaffinetransformation1.Rotation45degreeI=imread(cameraman.tif);T=maketform(affine,cosd(45)-sind(45)0;sind(45)cosd(45)0;001);tformfwd(1020,T);I2=imtransform(I,T);imshow(I2),MoreExample(cont.),2.TranslationI=imread(cameraman.tif);se=translate(strel(1),2525);J=imdilate(I,se);imshow(I),title(Original)figure,imshow(J),title(Translated);,MoreExample(cont.),3.shearI=imread(cameraman.tif);T=maketform(affine,100;120;001);tformfwd(1020,T);I2=imtransform(I,T);imshow(I2),MoreExample(cont.),Edgedetectors1.SobeledgedetectorCode:/BothhorizontalandverticalI=imread(cameraman.tif);BW2=edge(I,sobel,0.02,both);figure,imshow(BW2),MoreExample(cont.),2.theCannymethodlowthreshold:0.04,highthreshold:0.10,sigmais1Code:I=imread(cameraman.tif);BW4=edge(I,canny,0.040.10,1);figure,imshow(BW4),MoreExample(cont.),Canny以C语言来实作会困难很多!,MoreExample(cont.),Filter(meanfilter)Code:I=imread(coins.png);h=ones(5,5)/25;I2=imfilter(I,h);imshow(I),title(OriginalImage);figure,imshow(I2),title(FilteredImage),MoreExample(cont.),Filter(unsharpmaskingfilter)Code:I=imread(cameraman.tif);h=fspecial(unsharp);I2=imfilter(I,h);imshow(I),title(OriginalImage)figure,imshow(I2),title(FilteredImage),M-function不够用怎么办?,自己写。在网络上寻找高手的package。当找到新的M-files时,需帮它设定路径,才可以像一般内建function直接使用。,Setpath,Setpath(cont.),MATLABCompiler,MATLABCompiler能让您将MATLAB程序转换为可单独执行的应用程序和软件组件,并分享给其它使用者。MATLABCompiler可免除您经由手动编写方式将MATLAB程序代码转译为C或C+的程序。要再安装MATLABComponentRun-time(MCR)组件等。,MATLABCompiler(cont.),CtoMatlab设定了合适的编译器,matlab会自动帮我们编译这个程序。Example:helloworld指令:-编译:mexfilenameex:mexhello.c-执行:filenameex:hello,MATLABCompiler(cont.),hello.c#include#includemex.hvoidmexFunction(intnlhs,mxArray*plhs,intnrhs,constmxArray*prhs)printf(Hello,world.);mex.h定义了所有Matlab和C沟通所用到的subroutine。mexFunction是程序的进入点,等价于ANSIC的main。,參考書籍,DigitalImageProcessingUsingMATLABbyRafaelC.Gonzalez,RichardE.WoodsStevenL.Eddins,3个Projects,电能表读数识别人脸检测印刷线路板缺陷检测,电能表读数识别,对字轮进行精确定位与识别;对条码进行精确定位与识别,MatlabPackage,模式识别包:PRTools:/SPRTool:/wardlab/index_files/SPRTool.htmOCRMatlab例子:,人脸检测,OpenCV库:,印刷线路板缺陷检测,利用机器视觉、图像处理等技术,对印刷线路板上的诸如短路、断路、线距过窄过宽等各种缺陷进行自动检测。,类比,数位化,Binary,图像获取,CCD,类比,EIC,类比转数位资料线路A/D,数位化(Graylevel),图象处理卡,数位转换二进位资料线路,二进位图象(0或1),(Pixels):,铜箔,基材,CurrentScanline,检测缺点方式:,设计规范(DRC)检查,标准母板(REF)比较法,1.GoldenBoard:以量产板择一当作标准板,记录板上所有Feature位置,检测时与其它电路板比对藉以发现短断路之缺点.,优点:Fea

温馨提示

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

评论

0/150

提交评论