Skip to content

ENH: Support short axes in recursive Gaussian smoothing - #7001

Draft
sdiebolt wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
sdiebolt:enh/6997-short-dimension-gaussian-smoothing
Draft

sdiebolt wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
sdiebolt:enh/6997-short-dimension-gaussian-smoothing

Conversation

@sdiebolt

@sdiebolt sdiebolt commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Hi! This lets SmoothingRecursiveGaussianImageFilter skip axes shorter than four pixels while smoothing the remaining axes, including singleton slices used in registration. Closes #6997.

Scope and local testing
  • Preserve image dimensionality and geometry, and retain the existing processing order when every axis has at least four pixels.
  • Cast directly to the output type when all axes are short, avoiding an unnecessary float conversion.
  • Keep empty-image and nonpositive-sigma validation.
  • Leave recursive Gaussian gradients for a separate issue and PR; registration still needs both metric gradient-filter flags disabled for short dimensions.

Local checks on Linux:

  • Added GoogleTests for short-axis combinations, anisotropic sigma and spacing, geometry, repeated updates, in-place execution, integer/vector pixels, and two-level singleton-image registration.
  • All 14 focused CTest entries passed, including the unchanged smoothing MD5 baseline; the image-adaptor test also passed when invoked directly.
  • A new regression test compiled against unmodified main headers failed with the expected four-pixel exception.
  • Rebuilt the Python registration bindings and ran the exact example from ENH: Support singleton and short dimensions in SmoothingRecursiveGaussianImageFilter #6997 unchanged. Both sigma=1.0 and sigma=0.0 recovered the expected 4-pixel X translation.
  • All local commit hooks passed. Full-suite, cross-platform, and performance validation remain pending.
PR Checklist

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

No public API additions or new wrapped classes. The class documentation describes the short-axis behavior; both new test files have the standard license header. No separate examples contribution is needed for this enhancement.

AI assistance

AI assistance contributed to diagnosis, implementation, and regression tests. Focused C++ and Python checks passed locally.

@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module labels Oct 23, 2026
@sdiebolt

Copy link
Copy Markdown
Contributor Author

The Linux Python failure looks unrelated to this change: Gaussian smoothing passes, and the only failure among 185 tests is the median filter’s type-hint check (NameError: name 'xr' is not defined). The affected type alias and test are unchanged by this PR. This matches the failure observed in #7002.

@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.

Mostly looks good. I have not taken such a good look at tests besides ShortAxesAndRepeatedUpdates.

}

ImageType::Pointer
SmoothEligibleAxes(const ImageType * input, const FilterType::SigmaArrayType & sigma)

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.

This largely duplicates filter's functionality. Whenever the filter is updated, this needs to be updated too. I would prefer a simpler test, with some simple-to-reason-about constants. If we want to make sure that the filter's output does not drift, we should add a new image regression baseline with the expected output. That is better/easier to do via classic test, as opposed to GTest.

Allow singleton slices to retain smoothing along their longer axes.
Recursive gradient filtering remains a separate follow-up.

Closes InsightSoftwareConsortium#6997
@hjmjohnson
hjmjohnson force-pushed the enh/6997-short-dimension-gaussian-smoothing branch from 79d8d43 to 2605ef9 Compare November 4, 2026 01:38
@hjmjohnson

Copy link
Copy Markdown
Member

Rebase only: onto current upstream/main. The conflict was in RegistrationMethodsv4/test/CMakeLists.txt; the new ShortDimensions GTest now sits in the same list as the SyN GTest, with one driver call. Build and the short-axis and Smoothing GTests pass locally.

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

Labels

area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Support singleton and short dimensions in SmoothingRecursiveGaussianImageFilter

3 participants