[ITK] [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/community/attachments/20160202/4c708a3e/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list