Repository navigation
Support streaming in Gaussian interpolate image function - #998
Conversation
|
OK, this needs a pass on Linux compiler compatibility. On it. |
c68f083 to
e6eaaaf
Compare
|
It passes the tests now. Please review. |
|
@dzenanz Needs merge conflict resolution. |
e6eaaaf to
e6145f6
Compare
e6145f6 to
8d9f21d
Compare
There was a problem hiding this comment.
Many thanks @dzenanz for investigating this.
ITK compiles all fine in my test case and the streaming now runs without any errors but the result is not the same as without streaming, see the differing MD5s in e.g.
https://gitlab.com/romangrothausmann/ITK-CLIs_GL/-/jobs/226732768
|
@dzenanz What is the reason why a random input image did not trigger this problem while |
|
Maybe because I supplied .nhdr file, and NRRD does not support streaming even for reading? In retrospect, I should have paid more attention to that. |
|
An updated code points out the differences. #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->SetInput(filter->GetOutput());
try
{
writer->SetFileName("C:/Misc/Tester/out1.mha");
writer->SetNumberOfStreamDivisions(1);
writer->Update();
writer->SetFileName("C:/Misc/Tester/out4.mha");
writer->SetNumberOfStreamDivisions(4);
writer->Update();
}
catch (itk::ExceptionObject& exc)
{
std::cout << exc;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
} |
That I do not observe to be the difference for the MD5s (tested with writing to MHDs: MHDs identical, MD5s of RAWs differ), instead |
|
Well, how about you modify the current MWE to demonstrate the problem? |
|
Working on that (https://gitlab.com/romangrothausmann/ITK-CLIs/commits/debugGaussRes), with local testing I do get differing MD5s as soon as I put in before |
|
However, removing |
|
The I will merge this PR, as it is a noticeable improvement (no crashing, works well without ReleaseDataFlagOn). Can you create a new bug report, or even better a PR proposing a new test which demonstrates the problem with streaming+ReleaseDataFlagOn+GaussianInterpolateImageFunction? The MWE we have in this thread can be easily reworked into the desired regression test. Or perhaps update itkResampleImageTest7 to also test GaussianInterpolateImageFunction and ReleaseDataFlagOn? |
Approved.
That, or similar, hope to find the time for continuing debugging next week.
What could be the reason for that? Even with romangrothausmann/ITK-CLIs@1540e43 the non-streaming output lack the entry |
|
I have never used the |
|
@blowekamp all other interpolators in my |
|
I think I tried linear, and it worked correctly. |
|
Found a way to reproduce the problem, just scoping all and running the streaming separately: romangrothausmann/ITK-CLIs@eb81cb5 |
|
Not sure though why the version without scoping behaves differently. Could it be that the filter is not re-executed even though it has |
…nInterpolate Support streaming in Gaussian interpolate image function
…nInterpolate Support streaming in Gaussian interpolate image function
Closes #988.
PR Checklist