Skip to content

Error when resampling with Gaussian interpolation when employing streaming #988

Closed

Description

@romangrothausmann

Regarding #668, exercising Gaussian interpolation (including #958) still leads to an error in my test case (using ITK @ 8f67778) employing streaming:
https://gitlab.com/romangrothausmann/ITK-CLIs/-/jobs/223961167

itk::ExceptionObject (0x7fc848002c90)
Location: "unknown" 
File: /opt/itk/include/ITK-5.1/itkImageConstIteratorWithIndex.hxx
Line: 86
Description: itk::ERROR: Region ImageRegion (0x7fc8c9b11a18)
  Dimension: 3
  Index: [0, 0, 80]
  Size: [8, 8, 18446744073709551596]
 is outside of buffered region ImageRegion (0x1594768)
  Dimension: 3
  Index: [0, 0, 64]
  Size: [217, 202, 60]

Activity

  1. added
    type:Bug
    on Jun 3, 2019
  2. romangrothausmann commented on Jun 3, 2019

    @romangrothausmann
    MemberAuthor

    Relating to #958 (comment) @dzenanz any idea what could still be wrong?

  3. dzenanz commented on Jun 3, 2019

    @dzenanz
    Member

    If you boil it down to a minimal example, I could look into it.

  4. maekclena commented on Jun 4, 2019

    @maekclena
    Contributor

    I tried to create a minimal example:

    #include <itkImageFileReader.h>
    #include <itkResampleImageFilter.h>
    #include <itkGaussianInterpolateImageFunction.h>
    #include <itkImageFileWriter.h>
    
    using ImageType = itk::Image<int, 3>;
    using ReaderType = itk::ImageFileReader<ImageType>;
    using FilterType = itk::ResampleImageFilter<ImageType, ImageType>;
    using InterpolatorType = itk::GaussianInterpolateImageFunction<ImageType>;
    using WriterType = itk::ImageFileWriter<ImageType>;
    
    int main(int argc, char** argv)
    {
      ReaderType::Pointer reader = ReaderType::New();
      reader->SetFileName(argv[1]);
      reader->UpdateOutputInformation();
      ImageType::Pointer input = reader->GetOutput();
      
      FilterType::Pointer filter = FilterType::New();
      filter->SetInput(reader->GetOutput());
      filter->SetInterpolator(InterpolatorType::New());
      filter->SetSize(input->GetLargestPossibleRegion().GetSize());
      filter->SetOutputOrigin(input->GetOrigin());
      
      WriterType::Pointer writer = WriterType::New();
      writer->SetFileName("out.vtk");
      writer->SetInput(filter->GetOutput());
      writer->SetNumberOfStreamDivisions(4);
      writer->Update();
    }

    Also, the very large size reminds me of #734.

  5. romangrothausmann commented on Jun 5, 2019

    @romangrothausmann
    MemberAuthor

    Many thanks @maekclena for the minimal example, I'm sorry my response time is quite reduced at the moment. I was planning to create a test case for the test suit but won't be able to do so till end of next week.

    In contrast to the example above, my resample CLI also sets:

        typedef itk::IdentityTransform<TCoordRep, Dimension> TransformType;
        typename TransformType::Pointer transform= TransformType::New();
        transform->SetIdentity();
    
        filter->SetTransform(transform);
        filter->SetOutputSpacing(outputSpacing);
        filter->SetOutputDirection(input->GetDirection());
        filter->SetDefaultPixelValue(itk::NumericTraits<InputPixelType>::Zero);
        filter->ReleaseDataFlagOn();
    

    https://github.com/romangrothausmann/ITK-CLIs/blob/f146e2f5100564052f1f5080fc26dd51bc31516d/resample.cxx#L80-L90

    Can images be stored in VTK files? I always only used VTI so far. In the failing test case of mine, uncompressed MHD is used for input and uncompressed MHA for output.

  6. dzenanz commented on Jun 5, 2019

    @dzenanz
    Member

    I tried this with a random input image on my computer and it worked fine:

    #include <itkImageFileReader.h>
    #include <itkResampleImageFilter.h>
    #include <itkGaussianInterpolateImageFunction.h>
    #include <itkImageFileWriter.h>
    
    using ImageType = itk::Image<int, 3>;
    using ReaderType = itk::ImageFileReader<ImageType>;
    using FilterType = itk::ResampleImageFilter<ImageType, ImageType>;
    using TransformType = itk::IdentityTransform<double, 3>;
    using InterpolatorType = itk::GaussianInterpolateImageFunction<ImageType>;
    using WriterType = itk::ImageFileWriter<ImageType>;
    
    int main(int argc, char** argv)
    {
        ReaderType::Pointer reader = ReaderType::New();
        reader->SetFileName(argv[1]);
        reader->UpdateOutputInformation();
        ImageType::Pointer input = reader->GetOutput();
    
        typename TransformType::Pointer transform = TransformType::New();
        transform->SetIdentity();
        typename ImageType::SpacingType outputSpacing;
        outputSpacing.Fill(1.0);
    
        FilterType::Pointer filter = FilterType::New();
        filter->SetInput(reader->GetOutput());
        filter->SetInterpolator(InterpolatorType::New());
        filter->SetSize(input->GetLargestPossibleRegion().GetSize());
        filter->SetOutputOrigin(input->GetOrigin());
    
        filter->SetTransform(transform);
        filter->SetOutputSpacing(outputSpacing);
        filter->SetOutputDirection(input->GetDirection());
        filter->SetDefaultPixelValue(0);
        filter->ReleaseDataFlagOn();
    
        WriterType::Pointer writer = WriterType::New();
        writer->SetFileName("C:/Misc/Tester/out.mha");
        writer->SetInput(filter->GetOutput());
        writer->SetNumberOfStreamDivisions(4);
        writer->Update();
    }
  7. maekclena commented on Jun 5, 2019

    @maekclena
    Contributor

    I tested ACN_speed.mhd and a random image and both failed.

  8. dzenanz commented on Jun 5, 2019

    @dzenanz
    Member

    OK, that image triggers the exception for me.

  9. dzenanz commented on Jun 5, 2019

    @dzenanz
    Member

    BoundingBox is not updated with streaming, so end ends up being smaller then begin.

    Now off to fixing this.

  10. romangrothausmann commented on Jun 6, 2019

    @romangrothausmann
    MemberAuthor

    Many thanks @dzenanz and @maekclena for looking into this.

  11. dzenanz commented on Jun 6, 2019

    @dzenanz
    Member

    The bug was not trivial as I first thought, but I didn't want to give up halfway through. It is almost ready - I have to adjust the derived LabelImageGaussianInterpolateImageFunction class too.

  12. dzenanz commented on Jun 6, 2019

    @dzenanz
    Member

    #998 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions