Skip to content

ENH: Expand ResampleImageFilter requested region by interpolator domain - #668

Merged
dzenanz merged 1 commit into
InsightSoftwareConsortium:masterfrom
thewtex:resample-interpolator-domain
May 16, 2019
Merged

dzenanz merged 1 commit into
InsightSoftwareConsortium:masterfrom
thewtex:resample-interpolator-domain

Conversation

@thewtex

@thewtex thewtex commented Apr 1, 2019 •

Copy link
Copy Markdown
Member

When streaming during resampling, the requested region is extended by
the domain of the interpolator. This is especially important for
consistent resampling results with interpolators other than the nearest
neighbor or linear interpolator, which use many surrounding pixels to
determine their value.

A new, abstract GetRadius method is added to InterpolateImageFunction.
This method is used by the ResampleImageFilter to extend its required
input region.

Suggested-by: Bradley Lowekamp [email protected]

PR Checklist

@thewtex
thewtex force-pushed the resample-interpolator-domain branch 2 times, most recently from 96c826e to aede972 Compare April 2, 2019 13:35
@thewtex
thewtex force-pushed the resample-interpolator-domain branch from aede972 to 17d23c4 Compare April 9, 2019 19:20
@romangrothausmann

romangrothausmann commented Apr 25, 2019 •

Copy link
Copy Markdown
Member

Many thanks @thewtex for tackling this problem. I had a look at the failing tests and noticed that the comparison with the baseline is disabled in current master:

itk_add_test(NAME itkResampleImageTest2Streaming
COMMAND ITKImageGridTestDriver
#--compare DATA{Baseline/ResampleImageTest2.mha}
#${ITK_TEST_OUTPUT_DIR}/ResampleImageTest2aStreaming.mha
#--compare DATA{Baseline/ResampleImageTest2.mha}
#${ITK_TEST_OUTPUT_DIR}/ResampleImageTest2bStreaming.mha
#--compare DATA{Baseline/ResampleImageTest2NearestExtrapolate.mha}
#${ITK_TEST_OUTPUT_DIR}/ResampleImageTest2cStreaming.mha
#--compare DATA{Baseline/ResampleImageTest2NearestExtrapolate.mha}
#${ITK_TEST_OUTPUT_DIR}/ResampleImageTest2dStreaming.mha

It is not clear to me why and what was the last reason for that decision since they use linear interpolation
using InterpolatorType = itk::LinearInterpolateImageFunction<ImageType,CoordRepType>;

which already works with itkResampleImageTest7.
So I'd say that the failure of itkResampleImageTest7 is actually the critical one,
and comparison with the baseline itkResampleImageTest2Streaming should be tested separately on master (and should succeed already if itkResampleImageTest7 does), since the MHAs for the expected outcome were created without employing streaming.

@N-Dekker N-Dekker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions only. :-)

@thewtex thewtex added this to the ITK v5.0.0 milestone May 10, 2019
@thewtex
thewtex requested a review from dzenanz May 13, 2019 14:33
@dzenanz
dzenanz force-pushed the resample-interpolator-domain branch from 17d23c4 to 3363d4a Compare May 15, 2019 17:24
@dzenanz

dzenanz commented May 15, 2019

Copy link
Copy Markdown
Member

I applied Niels' suggestions and rebased. Doing this to refresh CI results. PR is not yet finished.

@dzenanz

dzenanz commented May 15, 2019

Copy link
Copy Markdown
Member

Separating test enablement into #872.

@blowekamp

Copy link
Copy Markdown
Member

I have worked on the interpolation in the LinearThreadedGenerateData and encountered many issues the portability of round and numerical precissions. I'd recommend extending the padding by at least 0.5 in continuous index space before rounding or 1 afterwards.

@dzenanz
dzenanz force-pushed the resample-interpolator-domain branch from 3363d4a to e64d922 Compare May 15, 2019 18:45
@dzenanz
dzenanz marked this pull request as ready for review May 15, 2019 18:47
@dzenanz

dzenanz commented May 15, 2019

Copy link
Copy Markdown
Member

This passes tests on my computer, and is ready for review.

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It makes no sense for me to "approve" because I last touched the PR.

@dzenanz dzenanz changed the title WIP: ENH: Expand ResampleImageFilter requested region by interpolator… ENH: Expand ResampleImageFilter requested region by interpolator… May 15, 2019
@dzenanz dzenanz changed the title ENH: Expand ResampleImageFilter requested region by interpolator… ENH: Expand ResampleImageFilter requested region by interpolator domain May 15, 2019
@blowekamp

Copy link
Copy Markdown
Member

Looks pretty good to me. Just a couple questions about how best to indicate that an interpolator needs the whole image.

When streaming during resampling, the requested region is extended by
the domain of the interpolator. This is especially important for
consistent resampling results with interpolators other than the nearest
neighbor or linear interpolator, which use many surrounding pixels to
determine their value.

A new, abstract GetRadius method is added to InterpolateImageFunction.
This method is used by the ResampleImageFilter to extend its required
input region.

Suggested-by: Bradley Lowekamp <[email protected]>
@dzenanz

dzenanz commented May 15, 2019 •

Copy link
Copy Markdown
Member

My next force-push applies Brad's suggestions. I am waiting for current CI results to come in before pushing this next amend.

Edit: the CI came back green.

@dzenanz
dzenanz force-pushed the resample-interpolator-domain branch from e64d922 to e4003fc Compare May 15, 2019 21:08

@thewtex thewtex left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks @dzenanz @blowekamp !

@dzenanz
dzenanz merged commit 72eea7b into InsightSoftwareConsortium:master May 16, 2019
@thewtex
thewtex deleted the resample-interpolator-domain branch May 16, 2019 14:26
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…e-interpolator-domain

ENH: Expand ResampleImageFilter requested region by interpolator domain
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 12, 2026
…e-interpolator-domain

ENH: Expand ResampleImageFilter requested region by interpolator domain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants