[Insight-users] Error when using HybridSegmentationFuzzyVoronoi with 3D image

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 30 08:32:51 EDT 2008


Hi Sara,

Please add try/catch blocks around all invocations of the Update()
method. You have three of them in your code at this point.

One of them is throwing an Exception, with an error message telling
you what the problem is...  and we are not listening to it.

You will find many examples on how to use try/catch blocks in the
ITK Software Guide


        http://www.itk.org/ItkSoftwareGuide.pdf


It should look like:

     try
       {
       filter->Update();
       }
     catch( itk::ExceptionObject & excp )
      {
      std::cerr << excp << std::endl;
      }


Please give it a try, and post to the list the error messages that
you get from the Excetptions.


    Thanks


        Luis


----------------------------
sara meghellati wrote:
>  
> 
> Hi Luis and itk users,
> 
> I’ve tried HybridSegmentationFuzzyVoronoi with 2D images and its working 
> fine. When I try to do the segmentation using the same filter with 3D 
> image I get the error:
> 
> Unhandled exception at 0x00418286 in HybridSegmentation.exe: 0xC0000005: 
> Access violation reading location 0x35847334.
> 
> Any help ?
> 
> I past my code bellow.
> 
> Thank you
> 
> Sara
> 
>  
>  
> // HybridSegmentationFuzzyVoronoi 3D image
> #include "itkSimpleFuzzyConnectednessScalarImageFilter.h"
> #include "itkVoronoiSegmentationImageFilter.h"
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkRescaleIntensityImageFilter.h"
>  
> int main( void)
> {
> typedef float InputPixelType;
> typedef unsigned char BinaryPixelType;
> typedef unsigned char OutputPixelType;
> const unsigned int Dimension = 3;
> typedef itk::Image< InputPixelType, Dimension > InputImageType;
> typedef itk::Image< BinaryPixelType, Dimension > BinaryImageType;
> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
> typedef 
> itk::SimpleFuzzyConnectednessScalarImageFilter<InputImageType,BinaryImageType> 
> FuzzySegmentationFilterType;
> typedef itk::VoronoiSegmentationImageFilter<InputImageType, 
> OutputImageType,BinaryImageType> VoronoiSegmentationFilterType;
> typedef itk::ImageFileReader< InputImageType > ReaderType;
> typedef itk::ImageFileWriter< OutputImageType > WriterType;
> FuzzySegmentationFilterType::Pointer fuzzysegmenter 
> =FuzzySegmentationFilterType::New();
> VoronoiSegmentationFilterType::Pointer voronoisegmenter = 
> VoronoiSegmentationFilterType::New();
> ReaderType::Pointer reader = ReaderType::New();
> WriterType::Pointer writer = WriterType::New();
> reader-SetFileName("C:/ Images/BrainPart2/Brain/brainweb165a10f17.mha" );
> writer->SetFileName("C:/mages/HybridSegmentationFuzzyVoronoi.hdr");
> InputImageType::IndexType index;
> index[0] = 123;
> index[1] = 110;
> index[2] = 96;
> const float mean = 140;
> const float variance = 30;
> const float meanTolerance = 0.2;
> const float stdTolerance = 2.0;
>  
> fuzzysegmenter->SetInput( reader->GetOutput() );
> fuzzysegmenter->SetObjectSeed( index );
> fuzzysegmenter->SetMean( mean );
> fuzzysegmenter->SetVariance( variance );
> fuzzysegmenter->SetThreshold( 0.5 );
> fuzzysegmenter->Update();
> voronoisegmenter->SetInput( reader->GetOutput() );
> voronoisegmenter->TakeAPrior( fuzzysegmenter->GetOutput() );
> voronoisegmenter->SetMeanPercentError( meanTolerance );
> voronoisegmenter->SetSTDPercentError( stdTolerance );
> voronoisegmenter->SetMinRegion( 5);
> voronoisegmenter->Update();
> typedef itk::RescaleIntensityImageFilter< 
> OutputImageType,OutputImageType > ScalerFilterType;
> ScalerFilterType::Pointer scaler = ScalerFilterType::New();
> scaler->SetOutputMinimum( 0 );
> scaler->SetOutputMaximum( 255 );
> scaler->SetInput( voronoisegmenter->GetOutput() );
> writer->SetInput( scaler->GetOutput() );
> writer->Update();
> return 0;
> }
>  
>  
> 
> 


More information about the Insight-users mailing list