[Insight-users] Streaming and InPlaceImageFilter
Simon Rit
simon.rit at creatis.insa-lyon.fr
Mon Mar 21 10:06:06 EDT 2011
Hi,
I have a problem with InPlaceImageFilter when using streaming. When I
connect the input of an InPlaceImageFilter to a filter that has been
updated and try to write the output of this filter with
SetNumberOfStreamDivisions set e.g. to 2, only the first half of the
filter is updated. I have written a simple test case to reproduce this
problem (using ITK 3.20):
////////////////////////////////////////////////////////////////////////////////////////
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkMultiplyByConstantImageFilter.h>
int main(int argc, char * argv[])
{
typedef double PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
typedef itk::MultiplyByConstantImageFilter< ImageType, PixelType,
ImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetInput(reader->GetOutput());
filter->SetConstant(0.);
filter->SetInPlace(atoi(argv[2]));
typedef itk::ImageFileWriter< ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(filter->GetOutput());
writer->SetFileName(argv[3]);
writer->SetNumberOfStreamDivisions(2);
writer->Update();
return EXIT_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////////////
To run this testPgm, compile it, use a test image input.mha and run
successively:
$ testPgm input.mha 0 output0.mha
$ testPgm input.mha 1 output1.mha
output0.mha and output1.mha should be the same but are not: only half
of output1.mha is set to 0 instead of the full image.
I believe that the reason is the test "if (bufferedRegion ==
largestRegion)" in itkImageFileWriter.txx. With InPlaceImageFilter,
the region might be buffered but only the requested region has been
updated...
Am I missing something? Is this a (known) bug? Any easy fix?
Obviously, I can disable the inplace capability but I believe this
should be fixed since it concerns many filters.
Thanks in advance for your help!
Simon
NB: I had similar problems with StreamingImageFilter but I did not
investigate where the problem was in this case.
More information about the Insight-users
mailing list