[Insight-users] seg fault trying to read analyze image

Mark Roden mmroden at gmail.com
Wed Sep 21 14:40:46 EDT 2011


Hi all,

In continuation of what I posted a few days ago, I'm trying to write
out analyze images.  I think that this should be straightforward
enough, but I'm getting a SIGSEGV when the following line is run (I'm
using itk 3.20, built using Release With Debug Info on Ubuntu 11.04 in
qt with gcc v 4.5.2 in 64 bit mode)


    itk::AnalyzeImageIO::Pointer analyzeIO = itk::AnalyzeImageIO::New();

The stack trace then suggests that I'm prematurely deleting something:
0	??		0	0x7fffffffffff	
1	itk::SmartPointer<itk::AnalyzeImageIO>::UnRegister	itkSmartPointer.h	147	0x439f8f
2	itk::SmartPointer<itk::AnalyzeImageIO>::~SmartPointer	itkSmartPointer.h	64	0x436524
3	vtkPipelines::saveImgImage	vtkPipelines.cpp	1173	0x42fdde	<== this
is my conversion routine

The code then puts out:
    typedef itk::OrientedImage< signed short, 3 > CTImage;
    typedef itk::ImageFileWriter< CTImage> CTWriter;
    typedef itk::VTKImageToImageFilter<CTImage> VTKImageImportType;

    CTWriter::Pointer theWriter = CTWriter::New();

    theWriter->SetFileName(file.toStdString().c_str());

    VTKImageImportType::Pointer vtkImageToImageFilter =
VTKImageImportType::New();
    vtkImageToImageFilter->SetInput(image);
    vtkImageToImageFilter->Update();

    theWriter->SetInput(vtkImageToImageFilter->GetOutput());

    itk::AnalyzeImageIO::Pointer analyzeIO =
itk::AnalyzeImageIO::New(); <== failing here
    theWriter->SetImageIO(analyzeIO);

    try {
        theWriter->Update();
    } catch(itk::ExceptionObject ex){
        return;
    }
    theWriter->Delete();
    vtkImageToImageFilter->Delete();
    analyzeIO->Delete();
    return;

and then there's this error that's returned to the terminal:

WARNING: In /home/mvs/Documents/src/itk/ITK/Code/IO/itkAnalyzeImageIO.cxx,
line 1359
AnalyzeImageIO (0x7fffd8004620): ERROR: Analyze 7.5 File Format Only
Allows RPI, PIR, and RIP Orientation

Which is odd, since all I've done is instantiate the pointer.  Unless
the AnalyzeImageIO class can't be started up using an OrientedImage,
and must instead just be an Image?

Any ideas on how to solve this?

Thanks,
Mark


More information about the Insight-users mailing list