[Insight-users] ImageReader problem when ImageIO is set

Tomáš Kazmar Tomash.Kazmar at seznam.cz
Sun Jun 3 13:27:17 EDT 2007


Hi,

  I need to read a dicom image using a ImageFileReader with imageIO set
to an instance of GDCMImageIO. The problem is that when the image is
corrupted the process just dies (due to a segfault in ImageFileReader::Update()).
IMHO, this is not a correct behavior which could be something like throwing
an exception. Does anyone know how to solve this?


Regards,
Tomas


Here is a minimal example to reproduce the error:

#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkGDCMImageIO.h>

typedef unsigned char PixelIOType;
typedef itk::Image<PixelIOType, 3>       ImageType;
typedef itk::GDCMImageIO                 ImageIOType;
typedef itk::ImageFileReader<ImageType>  ReaderType;

int main(int argc, char* argv[])
{
    ReaderType::Pointer reader = ReaderType::New();
    reader->SetFileName("corrupted_dicom_file");
    ImageIOType::Pointer dicomIO = ImageIOType::New();
    reader->SetImageIO(dicomIO);

    try {
        reader->Update();
    } catch (itk::ExceptionObject &ex) {
        std::cout << ex << std::endl;
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}


More information about the Insight-users mailing list