BUG: Smooth structure tensor with an isotropic Gaussian kernel#6602
Draft
physwkim wants to merge 1 commit into
Draft
BUG: Smooth structure tensor with an isotropic Gaussian kernel#6602physwkim wants to merge 1 commit into
physwkim wants to merge 1 commit into
Conversation
RecursiveGaussianImageFilter smooths along a single axis only (direction 0 by default). The structure tensor definition K_rho(grad(u_sigma) (x) grad(u_sigma)) requires an isotropic Gaussian kernel at both scales, smoothing every axis. Use SmoothingRecursiveGaussianImageFilter, which smooths all axes. Addresses item B22 of InsightSoftwareConsortium#6575.
Member
|
Status of this draft: blocked on baselines and now on a rebase conflict, and a high-effort automated review found two confirmed behavioral regressions in the smoothing swap. Blockers
Review findings (confirmed)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
StructureTensorImageFiltersmoothed the tensor field withRecursiveGaussianImageFilter, which filters one axis only. Fixing it invalidates all 16AnisotropicDiffusionLBRbaselines, so this is a draft pending a maintainer decision. Addresses B22 of #6575.Root cause
itkStructureTensorImageFilter.hxx:124builds the feature-scale (K_rho) smoother asusing GaussianFilterType = RecursiveGaussianImageFilter<TensorImageType>;RecursiveGaussianImageFilterderives fromRecursiveSeparableImageFilterand filters along a single direction —m_Direction, which defaults to 0 and is never set here. The structure tensorK_rho * (grad(u_sigma) (x) grad(u_sigma))requires an isotropic kernel, i.e. smoothing on every axis. The same mistake appears at:75for the noise-scale (K_sigma) smoother, on them_UseGradientRecursiveGaussianImageFilter == falsebranch (currently unreachable — the flag has no setter — but the same defect, so it is fixed too). Both now useSmoothingRecursiveGaussianImageFilter, which chains oneRecursiveGaussianImageFilterper axis.GradientRecursiveGaussianImageFilter, used elsewhere in the same file, already loopsSetDirection()over every axis and is correct.⚠ This changes filter output — 16 baselines are invalidated
Every
AnisotropicDiffusionLBRbaseline was generated against the axis-0-only smoothing, so all 16 image-comparison tests now fail with a nonzeroImageError(2 to 1.95e6 depending on the case):PacMan_cEED/cCED/I,FingerPrint_cEED/cCED/I,Cos3D_cCED,mrbrain_cEED,Lena_Detail_cCED_2/cEED_2/I_2,VectorField_Circle_cEED,Triangle_cEED/Triangle_EED,Oscillations1_cCED/Oscillations1_CED.The baselines have not been regenerated here — that is a maintainer call, and the new bytes need an ExternalData upload I cannot perform. Two questions for the maintainers:
The PR stays in draft until that is settled.
Local validation
New GoogleTest
itkStructureTensorImageFilterGTest.cxx, registered inAnisotropicDiffusionLBRGTests. Input is a step edge varying only along y and constant along x, so axis-0-only smoothing is a mathematical no-op on it and any response to the feature scale proves cross-axis smoothing.StructureTensorImageFilter.FeatureScaleSmoothsAlongAllAxes— fail-before:largeScaleTrace - smallScaleTracewas exactly0. Pass-after:rho=1gives5.97e-4,rho=8gives88.65.ITKSmoothingadded to the module'sDEPENDSfor the new include.AI assistance