在itk下canny水平集方法.docx_第1页
在itk下canny水平集方法.docx_第2页
在itk下canny水平集方法.docx_第3页
在itk下canny水平集方法.docx_第4页
在itk下canny水平集方法.docx_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

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

文档简介

在itk下canny水平集方法itklevelsetsegementation图像分割水平集 1. canny采用的是双阈值原理,双阈值算法对非极大值抑制图象作用两个阈值1和2,且212,从而可以得到两个阈值边缘图象N1i,j和 N2i,j。由于N2i,j使用高阈值得到,因而含有很少的假边缘,但有间断(不闭合)。双阈值法要在N2i,j中把边缘连接成轮廓,当到达轮廓的端点时,该算法就在N1i,j的8邻点位置寻找可以连接到轮廓上的边缘,这样, 算法不断地在N1i,j中收集边缘,直到将N2i,j连接起来为止。所以在本例的输入图像中还有幅来自 thresholdlevelset的结果,作为小阈值的(即N1)。 2.等值面问题 在thresholdlevelset滤波中,等值面Isosurface为0,而在canny中为127.5(均是对同一幅图像白质部分的分割) 答:先看看等值面是什么 The IsoSurfaceValue indicates which value in the input represents the interface of interest. By default, this value is zero. When the solver initializes, it will subtract the Iso SurfaceValue from all values, in the input, shifting the isosurface of interest to zero in the output.This image is a copy of the input with m_IsoSurfaceValue subtracted from each pixel. This way we only need to consider the zero level set in our* calculations. Makes the implementation easier and more efficient.即在设定一个等值面后,将会在处理图像之前对原图的每个像素减去等值面这个值,而等值面是小于但接近与图像中感兴趣部分的灰度值的,这样一减去后,20-127.5=0 150-127.50即感兴趣的部分呈现出来了 而不要的部分成了黑色的背景色。 那为什么threshold中的等值面设置为0呢?这个是因为threshold本身就是根据图像的原有灰度信息来设置阈值空间的,故这里不对原图像的灰度值进行改变!=*/#if defined(_MSC_VER)#pragma warning ( disable : 4786 )#endif#ifdef _BORLANDC_#define ITK_LEAN_AND_MEAN#endif/ Software Guide : BeginCommandLineArgs/ INPUTS: BrainProtonDensitySlice.png, ThresholdSegmentationLevelSetImageFilterVentricle.png/ OUTPUTS: CannySegmentationLevelSetImageFilterVentricle1.png/ 7.0 0.1 10.0 127.5 15#include itkImage.h/ Software Guide : BeginCodeSnippet#include itkCannySegmentationLevelSetImageFilter.h#include itkGradientAnisotropicDiffusionImageFilter.h/ Software Guide : EndCodeSnippet#include itkFastMarchingImageFilter.h#include itkBinaryThresholdImageFilter.h#include itkImageFileReader.h#include itkImageFileWriter.h#include itkZeroCrossingImageFilter.hint main( int argc, char *argv ) if( argc 9 ) std:cerr Missing Parameters std:endl; std:cerr Usage: argv0; std:cerr InputImage InitialModel OutputImage; std:cerr CannyThreshold ; std:cerr CannyVariance ; std:cerr AdvectionWeight; std:cerr InitialModelIsovalue; std:cerr MaximumIterations; std:cerr OutputSpeedImage std:endl; return 1; typedef float InternalPixelType; const unsigned int Dimension = 2; typedef itk:Image InternalImageType; typedef unsigned char OutputPixelType; typedef itk:Image OutputImageType; typedef itk:BinaryThresholdImageFilter ThresholdingFilterType; ThresholdingFilterType:Pointer thresholder = ThresholdingFilterType:New(); thresholder-SetUpperThreshold( 10.0 );/0水平集之上为分割部位? thresholder-SetLowerThreshold( 0.0 ); thresholder-SetOutsideValue( 0 ); thresholder-SetInsideValue( 255 ); typedef itk:ImageFileReader ReaderType; typedef itk:ImageFileWriter WriterType; ReaderType:Pointer reader1 = ReaderType:New(); ReaderType:Pointer reader2 = ReaderType:New(); WriterType:Pointer writer = WriterType:New(); reader1-SetFileName( argv1 ); reader2-SetFileName( argv2 ); writer-SetFileName( argv3 ); typedef itk:GradientAnisotropicDiffusionImageFilter DiffusionFilterType; DiffusionFilterType:Pointer diffusion = DiffusionFilterType:New(); diffusion-SetNumberOfIterations(5); diffusion-SetTimeStep(0.125); diffusion-SetConductanceParameter(1.0); typedef itk:CannySegmentationLevelSetImageFilter CannySegmentationLevelSetImageFilterType; CannySegmentationLevelSetImageFilterType:Pointer cannySegmentation = CannySegmentationLevelSetImageFilterType:New(); cannySegmentation-SetAdvectionScaling( :atof(argv6) );/此例设置为10 cannySegmentation-SetCurvatureScaling( 1.0 ); cannySegmentation-SetPropagationScaling( 0.0 ); cannySegmentation-SetMaximumRMSError( 0.01 );/误差设置相当小! cannySegmentation-SetNumberOfIterations( :atoi(argv8) ); cannySegmentation-SetThreshold( :atof(argv4) );/canny的阈值为各个坐标方向的梯度值的均方值 cannySegmentation-SetVariance( :atof(argv5) );/方差为高斯滤波函数的方差,cannyfilter包含了高斯滤波. cannySegmentation-SetIsoSurfaceValue( :atof(argv7) );/等值面! diffusion-SetInput( reader1-GetOutput() ); cannySegmentation-SetInput( reader2-GetOutput() ); cannySegmentation-SetFeatureImage( diffusion-GetOutput() ); thresholder-SetInput( cannySegmentation-GetOutput() ); writer-SetInput( thresholder-GetOutput() ); try writer-Update(); catch( itk:ExceptionObject & excep ) std:cerr Exception caught ! std:endl; std:cerr excep std:endl; std:cout std:endl; std:cout Max. no. iterations: GetNumberOfIterations() std:endl; std:cout Max. RMS error: GetMaximumRMSError() std:endl; std:cout std:endl; std:cout No. elpased iterations: GetElapsedIterations() std:endl; std:cout RMS change: GetRMSChange() 9 ) const char * speedImageFileName = argv9; / Software Guide : BeginLatex / / In some cases it is interesting to take a direct look at the speed image / used internally by this filter. This may help for setting the correct / parameters for driving the segmentation. In order to obtain such speed / image, the method codeGenerateSpeedImage() should be invoked first. / Then we can recover the speed image with the codeGetSpeedImage() method / as illustrated in the following lines. / / indexitk:Canny-Segmentation-LevelSet-Image-Filter!GenerateSpeedImage() / indexitk:Segmentation-LevelSet-ImageFilter!GenerateSpeedImage() / indexitk:Canny-Segmentation-LevelSet-Image-Filter!GetSpeedImage() / indexitk:Segmentation-LevelSet-ImageFilter!GetSpeedImage() / / Software Guide : EndLatex / Software Guide : BeginCodeSnippet cannySegmentation-GenerateSpeedImage(); typedef CannySegmentationLevelSetImageFilterType:SpeedImageType SpeedImageType; typedef itk:ImageFileWriter SpeedWriterType; SpeedWriterType:Pointer speedWriter = SpeedWriterType:New(); speedWriter-SetInput( cannySegmentation-GetSpeedImage() ); / S

温馨提示

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

评论

0/150

提交评论