[Insight-users] Error when using HybridSegmentationFuzzyVoronoi by 3D image
Fanqiang Li
lifanqiang at gmail.com
Fri Mar 18 17:00:59 EDT 2011
Hi 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 0x7c812afb in best_segmentation.exe: Microsoft C++
exception: itk::ImageFileReaderException at memory location 0x0142faa4
I past my code bellow. (I use step debug and find the error is caused by the
sentence between ==================)
Thank you
Qiang
// 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("brainMRI.mha" );
writer->SetFileName("brainMRISeg.mha");
InputImageType::IndexType index;
index[0] = 123;
index[1] = 138;
index[2] = 15;
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/20110318/18d14715/attachment-0001.htm>
More information about the Insight-users
mailing list