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

sara meghellati sara_meghellati at yahoo.fr
Thu Oct 16 14:36:39 EDT 2008


 
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;
}
 
 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081016/f6404efa/attachment-0001.htm>


More information about the Insight-users mailing list