[Insight-users] Trouble using the TileImageFilter

Erik Türke tuerke at cbs.mpg.de
Mon Nov 2 05:54:12 EST 2009


Luis Ibanez wrote:
> Hi Erik,
>
> The TileImageFilter expects you to provide a set of different
> Image pointers to the method:
>
>                tileImageFilter->PushBackInput(   );
>
> However, you are always calling this method with the argument:
>
>                     resampler->GetOutput());
>
> Since a filter owns its output, the resampler filter is providing the
> same image pointer every time.
>
> One possible solution here, is for you to disconnect the output
> of the resample filter before you connect it as input to the Tile
> filter. In this way the resample filter has to allocate a new image
> from scratch, and therefore it will provide a different image pointer
> every time.
>
> In sumary:
>
> Replace the line:
>
>     tileImageFilter->PushBackInput(  resampler->GetOutput()   );
>
> with the lines
>
>    OutputImageType::ConstPointer tileImage =
>            resampler->GetOutput();
>
>    tileImage->DisconnectPipeline();
>
>     tileImageFilter->PushBackInput( tileImage   );
>
>
> BTW:
> It is good that you are already calling "resampler->Update()"
> before you attempt to use resampler->GetOutput().
> This is important, since it guarantees that the output image
> is computed.
>
>
>       Regards,
>
>
>             Luis
>
>
> -----------------------------------------------------------------------------------------
> On Wed, Oct 28, 2009 at 1:28 PM, Erik Tuerke <tuerke at cbs.mpg.de> wrote:
>   
>> Hi!
>>
>> I have some trouble using the itk::TileImageFilter. :-(
>>
>> What i want to do is creating an 4d image with the help of this filter.
>>
>> Here is my approach:
>>
>> const unsigned int Dimension = 3;
>> const unsigned int fmriDimension = 4;
>>
>> typedef itk::Image<PixelType, Dimension> OutputImageType;
>> typedef itk::Image<PixelType, fmriDimension> FMRIOutputType;
>>
>> typedef itk::ImageFileWriter<FMRIOutputType> FMRIImageWriterType;
>>
>> typedef itk::TileImageFilter<OutputImageType, FMRIOutputType>
>> TileImageFitlerType;
>>
>> FMRIImageWriterType::Pointer fmriWriter = FMRIImageWriterType::New();
>> TileImageFitlerType::Pointer tileImageFilter = TileImageFitlerType::New();
>>
>> itk::FixedArray<unsigned int, 4> layout;
>> layout[0] = 1;
>> layout[1] = 1;
>> layout[2] = 1;
>> layout[3] = 0;
>> tileImageFilter->SetLayout(layout);
>>
>> for(unsigned int timestep = 0; timestep < numberOfTimeSteps; timestep++) {
>>       std::cout << "Resampling timestep: " << timestep << "...\r" <<
>> std::flush;
>>       timeStepExtractionFilter->SetRequestedTimeStep(timestep);
>>       timeStepExtractionFilter->Update();
>>       resampler->SetInput(timeStepExtractionFilter->GetOutput());
>>       resampler->Update();
>>
>>       //here it would be possible to save each image obtained from the
>> resampler. I have tested that...so this should not be the source of error
>>
>>       tileImageFilter->PushBackInput(resampler->GetOutput());
>> }
>> tileImageFilter->Update();
>> fmriWriter->SetInput(tileImageFilter->GetOutput());
>> fmriWriter->Update();
>>
>>
>> What  i am getting is a 4d image with dimension[3] = numberOfTimeSteps...as
>> expected.
>>
>> The problem is, that each timestep shows the same image (the last one).
>>
>> Has someone an idea what i am doing wrong here ??
>>
>> Thanks for yout help!!
>>
>>
>>
>>
>>
>>
>>
>> _____________________________________
>> 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.html
>>
>> 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://www.itk.org/mailman/listinfo/insight-users
>>
>>     
Hi!

Thanks for your help, works all fine now. The only thing i had to change 
was ConstPointer to Pointer.




More information about the Insight-users mailing list