[Insight-users] Bus Error/ Segmentation Fault with example
Jacob Boomgaarden
boomgaar at arsc.edu
Fri Jul 30 15:10:17 EDT 2004
Hello all,
I am running a simple example to use the ConfidenceConnectedImageFilter for
segmentation
on a two-dimensional jpg image and I continually encounter either a Bus error (core
dumped) or a Segmentation fault (core dumped) message when trying to run my program
Here is my program code:
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkCurvatureFlowImageFilter.h"
#include "itkConfidenceConnectedImageFilter.h"
#include "itkCastImageFilter.h"
int main(int argc, char **argv)
{
if( argc < 5)
{
std::cerr<< "Usage: " <<std::endl;
std::cerr<< argv[0] << "inputImageFile outputImagefile seedX seedY"<<std::endl;
return 1;
}
typedef float InputPixelType;
typedef unsigned char OutputPixelType;
const unsigned int Dimension = 2;
typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef itk::ImageFileWriter< OutputImageType > WriterType;
typedef itk::CurvatureFlowImageFilter<
InputImageType, InputImageType > NoiseFilterType;
typedef itk::ConfidenceConnectedImageFilter<
InputImageType, InputImageType > SegmentationFilterType;
typedef itk::CastImageFilter<
InputImageType, OutputImageType > CastingFilterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
NoiseFilterType::Pointer noisefilter = NoiseFilterType::New();
CastingFilterType::Pointer caster = CastingFilterType::New();
SegmentationFilterType::Pointer segmentfilter = SegmentationFilterType::New();
const char * inputfile = argv[1];
const char * outputfile = argv[2];
reader->SetFileName( inputfile );
writer->SetFileName( outputfile );
noisefilter->SetInput( reader->GetOutput() );
segmentfilter->SetInput( noisefilter->GetOutput() );
caster->SetInput( segmentfilter->GetOutput() );
writer->SetInput( caster->GetOutput() );
noisefilter->SetNumberOfIterations( 5 );
noisefilter->SetTimeStep( 0.125 );
segmentfilter->SetMultiplier( 2.5 );
segmentfilter->SetNumberOfIterations( 5 );
segmentfilter->SetReplaceValue( 255 );
InputImageType::IndexType index;
index[0] = atoi( argv[3] );
index[1] = atoi( argv[4] );
segmentfilter->SetSeed( index );
segmentfilter->SetInitialNeighborhoodRadius( 2 );
// Execute the pipeline within an error catching block
try
{
writer->Update();
}
catch( itk::ExceptionObject & excep )
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
return 1;
}
std::cout<<"All Done"<<std::endl;
return 0;
}
Here is what I type in as command line args: ctlungs.jpg newlungs.jpg 198 100
Thanks for any help you can provide,
--
Jacob Boomgaarden
ARSC Intern
West Ridge Research Building, Room 011
Phone: (907)-455-3350
Office: (907)-450-8701
Email: boomgaar at arsc.edu
More information about the Insight-users
mailing list