[ITK-users] Using ImageFileReader iteratively

Gib Bogle g.bogle at auckland.ac.nz
Tue Feb 2 18:48:46 EST 2016


I am reading a set of 2D image files, like this:

typedef itk::Image<unsigned char,2> ImageType2;        // 2D image
ImageType2::Pointer im2;
unsigned char *p2;

    typedef itk::ImageFileReader<ImageType2> FileReaderType;
    FileReaderType::Pointer reader = FileReaderType::New();

    for (z=0; z<z2-z1-1; z++) {
        ... // make frame_file
        printf("frame_file: %s\n",frame_file);
        reader->SetFileName(frame_file);
        try
        {
            reader->Update();
            printf("did reader->update\n");
        }
        catch (itk::ExceptionObject &e)
        {
            std::cout << e << std::endl;
            return 2;
        }

        im2 = reader->GetOutput();
        printf("got im2\n");
        ...
    }

This reads the first 2D file, but the next time through the loop it crashes while executing reader->Update().
What am I doing wrong?

Thanks
Gib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160202/4c708a3e/attachment.html>


More information about the Insight-users mailing list