Skip to content

BUG: AnisotropicDiffusionLBR and IsotropicWavelets both define itk::StructureTensorImageFilter #7057

Closed

Description

@hjmjohnson

Two modules define itk::StructureTensorImageFilter in headers with the same name and the same include guard, so a build that enables both cannot use both classes, and Python wrapping fails to compile.

Module Header Template Wrapped
AnisotropicDiffusionLBR (ingested in #6093) itkStructureTensorImageFilter.h <typename TImage, typename TTensorImage> no; used by AnisotropicDiffusionLBRImageFilter
IsotropicWavelets (ingested in #6267) itkStructureTensorImageFilter.h <typename TInputImage, typename TOutputImage> yes

Both modules are EXCLUDE_FROM_DEFAULT, so only builds that enable both are affected. With both enabled and ITK_WRAP_PYTHON=ON, the IsotropicWavelets wrapper resolves to the other class:

Wrapping/Modules/IsotropicWavelets/itkStructureTensorImageFilterPython.cpp: error: no member named 'SetNoiseScale' in
'itk::StructureTensorImageFilter<itk::Image<float>, itk::Image<itk::VariableSizeMatrix<double>>>'

(also SetFeatureScale and SetRescaleForUnitMaximumTrace, which are AnisotropicDiffusionLBR's setters). Both headers use the include guard itkStructureTensorImageFilter_h, so any translation unit that includes both silently gets whichever comes first in the include path, and the two classes violate the one-definition rule.

Possible fixes

Both are public API, so each option renames something users may refer to:

  1. Rename the AnisotropicDiffusionLBR class (for example LBRStructureTensorImageFilter), which is not wrapped and is mainly an implementation piece of AnisotropicDiffusionLBRImageFilter.
  2. Rename the IsotropicWavelets class, which is wrapped, so Python users would see the change.
  3. Merge them into one filter, if one can provide both behaviors.

Whichever is renamed cannot keep the old name as an alias without reintroducing the clash; a deprecation note in the migration guide would be the notice. Its header guard must change with it.

How it was found

The downstream build forest (every ITK consumer built against one ITK, with ITK_BUILD_DEFAULT_MODULES=ON, both modules enabled, and Python wrapping) stopped in the ITK build on this error while testing #7041 and #7056 on 2026-10-31. Neither PR touches these modules. The forest run disabled Module_IsotropicWavelets to proceed.

AI assistance (Claude Code) was used to diagnose the failure and draft this report.

Activity

  1. hjmjohnson commented on Oct 31, 2026

    @hjmjohnson
    MemberAuthor

    The two classes are different algorithms that share a name, so they cannot be merged into one copy. Plan: rename both, each staying in its own module (GradientStructureTensorImageFilter in AnisotropicDiffusionLBR, RieszStructureTensorImageFilter in IsotropicWavelets). Neither class is used outside its own module in ITK or in the downstream forest sources.

    How the two classes differ
    AnisotropicDiffusionLBR IsotropicWavelets
    Input one scalar or vector image; gradient computed inside 2 or more component images (SetInputs)
    Smoothing recursive Gaussian (NoiseScale, FeatureScale) truncated Gaussian-window convolution (GaussianWindowRadius, GaussianWindowSigma)
    Output SymmetricSecondRankTensor image VariableSizeMatrix image holding eigenvectors and eigenvalues
    Extras RescaleForUnitMaximumTrace projection, coherency, and rotation-matrix helpers
    Wrapped no yes

    A single class would need mode-dependent setters, two smoothing implementations, and different numerical results, so one copy in a common module is not proposed.

    Usage inside ITK
    • LBR class: its own header and .hxx, AnisotropicDiffusionLBRImageFilter.h/.hxx, and itkStructureTensorImageFilterGTest.cxx.
    • IsotropicWavelets class: its own header and .hxx, itkStructureTensorImageFilterTest.cxx, itkStructureTensorWithGeneralizedRieszTest.cxx, and wrapping/itkStructureTensorImageFilter.wrap.
    • Documentation: the ITK 6 migration guide section on StructureTensorImageFilter describes the LBR class and says its API is unchanged, so it needs updating.
    Downstream forest check

    Source search over the forest's 310 source trees, plus the forest build tree for ITK main:

    • StructureTensorImageFilter appears in no source file outside ITK.
    • MITK (BasicImageProcessing depends on IsotropicWavelets) and CaPTk enable Module_IsotropicWavelets; BRAINSTools enables Module_AnisotropicDiffusionLBR; SimpleITK wraps CoherenceEnhancingDiffusionImageFilter from the LBR module. None of them name either class, so the renames should not affect them. This is a source search, not a build of those consumers.
    • Not checked: Python users of the wrapped IsotropicWavelets class outside the forest (for example the itk-isotropicwavelets PyPI package). They would see the rename.
  2. hjmjohnson commented on Oct 31, 2026

    @hjmjohnson
    MemberAuthor

    Draft PR #7061 renames both classes (GradientStructureTensorImageFilter in AnisotropicDiffusionLBR, RieszStructureTensorImageFilter in IsotropicWavelets). Building both modules with Python wrapping then also hit a separate failure, tracked in #7058 and fixed in draft PR #7060; both are needed for that configuration.

    Results
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions