工业CT体绘制和缺陷分割统计算法研究及交互软件重庆大学硕士学位论文(学术学位)学生姓名:王成平指导教师:曾理教授专业:计算数学学科门类:理学重庆大学数学与统计学院二O一四年四月VolumeRenderingandDefectSegmentationAlgorithmResearchonIndustrialCTwithIntegratedSoftwareAThesisSubmittedtoChongqingUniversityinPartialFulfillmentoftheRequirementfortheMaster’sDegreeofScienceByChengpingWangSupervisedbyProf.LiZengSpecialty:ComputationalMathematicsCollegeofMathematicsandStatisticsofChongqingUniversity,Chongqing,ChinaApril,2014摘要计算机断层成像(Computedtomography,CT)以其无损、精确等优点广泛应用于医学、安检、工业等领域。随着制造业的不断发展,工业CT作为一种重要的检测手段得到了广泛地应用和推广。在工业制造领域中,由于受到客观条件的限制或者人为因素的影响,使得制造的工件(如发动机、气缸、铁路铸件等)出现裂纹、气孔、夹杂等缺陷,以至于工件的性能下降,使用寿命减少,影响了工件的整体合格率。为了在工件制造完成后了解工件的实际生产情况,可以对工件进行CT扫描,再通过CT重建得到工件内部断层数据,这些断层数据的可视化,对于技术人员观察工件内部结构和判断工件内部是否有缺陷,是一个非常直观有效的方法。体数据的可视化不仅可以帮助设计人员改进工业设计、优化制造流程,而且对于工业生产和检验有着重要的意义。对于多层断层图像数据,其可视化一般有切片直接显示、面绘制、体绘制等,切片显示可以很好地观察到每层的灰度结构,但其对整体三维结构不具有一目了然的效果;面绘制,作为一种经典的体数据可视化方法广泛应用于医学、工业等领域,其主要思想是通过提取体数据中等值面的基本几何图元,然后对这些基本图元进行投影绘制,由于其本身的特性,使得其适用于那些只关心物体表面结构的显示;体绘制,作为一种直接绘制体数据的方法,其思想是模仿射线穿过体数据并对其进行采样,然后对采样数据进行合成,最后将合成结果投影到成像平面形成二维画面,呈现出三维立体效果,这种直接采样方式,可以很好的保留体数据内部的信息,使得我们可以调控并显示感兴趣的内部信息。本文针对工业CT重建数据的特点(工件一般由几种简单材质组成,所以重建图像一般呈现几个常数灰度阶),采用光线投射体绘制算法,通过调节传递函数,使其达到边界过渡段(体数据中不同结构之间,由于插值引起的的灰度过度段)峰值模式,这样不仅可以显示工件的外部轮廓,同时也能显示其内部轮廓,对于同时观察工件整体外部结构以及内部结构提供有效的显示方式。而针对工件内部的缺陷,由于其体积较小,不能单纯通过边界过渡段来突出显示,于是我们首先利用三维CV(Chan-Vese)方法对体数据进行缺陷分割,然后利用三维区域生长对目标区域进行体积统计,通过制定体积参考量得到缺陷,而后重新规划体数据灰度,在进行光线投射算法时,通过调节传递函数,使其达到着重显示缺陷,弱化物体轮廓的效果。此方法可以在显示缺陷的同时,有效地保留工件的整体轮廓结构信息,使得在观察时,可以直观的感受到缺陷所在的相对位置及大小信息,这对于技术人员分析和改进工业设计提供了有效的帮助。光线投射算法由于其计算量大而使其在实际的应用系统中受到了一定的阻碍,但随着计算机技术的发展、高性能并行处理器GPU(GraphicProcessingUnit)的不断推新以及其对应的CUDA(ComputeUnifiedDeviceArchitecture)框架的推出,使得科学计算行业得到了迅猛的发展。由于光线投射算法具有高度的并行性,我们将每条射线对应到一个虚拟的GPU核上,最终的加速使得其可以达到人机交互的显示频率。最后,借助于MFC(MicrosoftFoundationClasses)与SDMV(SingleDocumentMultiView)模型得到软件的整体框架,并将工业CT重建体数据显示软件分成了几个模块,进行单独编码、调试并生成DLL(DynamicLinkLibrary),再通过组合这些功能,形成了一个较为完整且扩展性良好的工业CT重建数据体绘制软件。关键字:工业CT,体绘制,三维CV模型,三维区域生长,CUDA,三维显示ABSTRACTCT(Computedtomography)foritsnon-destructive,accurate,etc.arewidelyusedinmedical,security,industrialandotherfields.Withthecontinuousdevelopmentofmanufacturing,industrialCTasanimportantmeansofdetectionhasbeenwidelyusedandpromoted.Inthefieldofindustrialmanufacturing,duetothelimitofobjectiveconditionsortheimpactofhumanfactors,makingtheWorkpiece(suchasengines,cylinder,railwaycastings,etc.)cracks,porosity,inclusionsandotherdefects,thatmakestheperformanceoftheworkpiecedecline,reducestheworkpiece'slife,andaffectstheoverallpassrateoftheworkpiece.Tounderstandtheactualproductionoftheworkpieceaftermanufacturingcomplete,theCTscancanbeusedontheworkpiece,andthenwocangettheinternalpiecetomographicdatabyCTreconstruction,thevisualizationoftomographicdataisaveryintuitiveandeffectivemethodfortechnicalpersonneltoobservetheinternalstructureanddeterminewhethertheinternalofworkpieceisdefectiveornot.Thevisualizationofvolumedatacannotonlyhelpdesignersimproveindustrialdesign,optimizemanufacturingprocesses,butalsohasimportantsignificanceforindustrialproductionandinspection.Formultilayertomographicimagedata,thevisualizationaregenerallydirectslicedisplaying,surfacerendering,volumerendering,etc.,thedirectslicedisplayingcanbewellobservedinthestructureofeachgradation,butitdoesnothaveacleareffectontheoverallthree-dimensionalstructure;thesurfacerendering,asaclassicvolumedatavisualizationmethod,arewidelyusedinmedicine,industryandotherfields,themainideaistoextractisosurfaceofvolumedatawithbasicgeometricprimitives,andthenrendertheprojectionoftheseprimitives,becauseofitsownlimitations,makingitsuitableforthosedisplayswhichareonlyinterestedinthesurfacestructureoftheobject;volumerendering,asadirectrenderingmethodofthevolumedata,themainideaistomimicrayspassthroughthebodyofthevolumedata,andsamplesynthesisontheseraystoformattwo-dimensionalimageontothescreen,thevolumerenderingresultshowsathree-dimensionaleffect,duetoit'sdirectsampling,thedatainsidethebodycanbewellpreserved,andwecanregulateanddisplaytheinternalinformationofinterestbythetransferfunction.Inthispaper,inconnectionwiththecharacteristicsofindustrialCTreconstructiondata(generallyseveralsimpleworkpiecematerialcomposition,sothereconstructedimageisgenerallypresentedseveralconstantgraybands),usingraycastingalgorithmbyadjustingthetransferfunction,sothatitreachestheboundary(thevolumedatabetweendifferentstructures,thegradationcausedbyexcessiveinterpolationsection)peakmode,itcannotonlyshowtheexternalcontouroftheworkpiece,butalsoshowitsinteriorcontour,it'saneffectivedisplaywayforobservingtheexternalandinternalstructureoftheworkpiecesimultaneously.Andfordefectswithintheworkpiece,duetotheirsmallersize,cannotsimplybedisplayedbythegradationtransitionsection,sowefirstusethethree-dimentionCV(Chan-Vese)modeltosegmentthedefectsofthevolumedata,thenusethethree-dimensionalregiongrowingmethodtostatisticsthevolumeofthetargetareas,thedefectsareobtainedbyreferencetothethegiventhreshold,andthenre-planningthegrayofthevolumedata,duringtheray-castingalgorithm,byadjustingthetransferfunctiontoreachtheemphasisofdisplayingdefects,