[ITK] [ITK-users] Using ImageFileReader iteratively

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


Hi Matt,

Indeed it was!  Just a careless oversight.  It's all working now.

Cheers, Gib
________________________________________
From: Matt McCormick [matt.mccormick at kitware.com]
Sent: Wednesday, 3 February 2016 3:17 p.m.
To: Gib Bogle
Cc: insight-users
Subject: Re: [ITK-users] Using ImageFileReader iteratively

Hi Gib,

It may be related to what is happening in "...".

Try

  im2->DisconnectPipeline();

after

  im2 = reader->GetOutput();

This will disassociate the output image from the reader object, and
the reader will create a new output image in the next iteration of the
loop.

HTH,
Matt

On Tue, Feb 2, 2016 at 6:48 PM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
> 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
>
> _____________________________________
> 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
>
_____________________________________
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