Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f30c6ba
ENH: Converting generic_label_interpolator to an ITK remote module.
fbudin69500 May 24, 2016
e107225
ENH: Replacing M_PI with itk::Math::pi
fbudin69500 May 30, 2016
fea9737
ENH: Remove unused variables warning
fbudin69500 May 31, 2016
4e0250b
BUG: m_Alpha and m_Sigma are private variables
fbudin69500 Oct 13, 2016
c93d77d
ENH: Require cmake minimum version to be 3.9.5.
Jan 17, 2018
bb73f94
ENH: ITKv5 override consistency
hjmjohnson Dec 17, 2017
3828cfb
COMP: Use C++11 override directly
hjmjohnson Dec 17, 2017
8478c95
COMP: Use nullptr instead of 0 or NULL
hjmjohnson Dec 17, 2017
34267a5
STYLE: Modernize to C++11 conventions
hjmjohnson Feb 12, 2018
08a743a
STYLE: Replace itkStaticConstMacro with static constexpr
hjmjohnson Feb 13, 2018
091cd46
STYLE: Prefer C++11 type alias over typedef
hjmjohnson Feb 13, 2018
45c6408
STYLE: Prefer constexpr for const numeric literals
hjmjohnson Feb 13, 2018
0730ff7
COMP: Move ITK_DISALLOW_COPY_AND_ASSIGN calls to public section.
Apr 14, 2018
49c357f
COMP: Set the minimum required CMake version to 3.10.2.
May 5, 2018
4826360
ENH: Add missing CI components.
jhlegarreta Dec 21, 2018
2bd5803
DOC: Improve the module documentation.
jhlegarreta Dec 18, 2018
a8dea93
COMP: Interpolators now must provide GetRadius()
hjmjohnson May 17, 2019
f0d92c6
STYLE: Use more ITKv5 style conformance.
hjmjohnson May 17, 2019
2b56ef2
COMP: Missing constructor definition.
hjmjohnson May 17, 2019
9e9ba84
ENH: Update itkLabelImageGenericInterpolateImageFunction.h
yinkaola Aug 2, 2019
c515874
ENH: Update itkLabelImageGenericInterpolateImageFunction.hxx
yinkaola Aug 2, 2019
f5cfa8a
STYLE: replacing MD5 hashes by SHA512 hashes
dzenanz Aug 13, 2019
d89fccd
STYLE: Use override statements for C++11
hjmjohnson Feb 17, 2020
6dbbc10
STYLE: Prefer = default to explicitly trivial implementations
hjmjohnson Feb 17, 2020
0ca1f92
STYLE: Use auto for variable type matches the type of the initializer…
hjmjohnson Feb 18, 2020
36a9197
DOC: Update copyright assignment to NumFOCUS
hjmjohnson Feb 19, 2020
0f6d673
ENH: Make similar to template
hjmjohnson Mar 1, 2020
533abc6
COMP: Fix Wrapping Errors
sudomakeinstall May 21, 2020
99f7439
STYLE: Rename ITK_DISALLOW_COPY_AND_ASSIGN to ITK_DISALLOW_COPY_AND_M…
mseng10 Oct 14, 2020
9b4a3b8
COMP: Remove inclusion of .hxx files as headers
hjmjohnson Dec 17, 2021
f365bca
ENH: update minimum required CMake version
dzenanz Dec 29, 2021
feee9c1
ENH: Bump ITK and replace http with https using script
tbirdso May 31, 2022
4e6c239
COMP: Define interpolator template parameter names
thewtex Sep 19, 2022
ecce950
COMP: Use modern macro for name of class
hjmjohnson Jan 25, 2025
195fdab
ENH: Reduce image size of rotate resampling test
blowekamp Apr 14, 2025
790436d
ENH: Ingest ITKGenericLabelInterpolator into Modules/Filtering
hjmjohnson Apr 27, 2026
4441e31
COMP: Drop missing README.rst read in ingested GenericLabelInterpolator
hjmjohnson Apr 25, 2026
e806372
COMP: Remove GenericLabelInterpolator.remote.cmake; now in-tree
hjmjohnson Apr 25, 2026
df55563
ENH: Enable GenericLabelInterpolator in CI via configure-ci
hjmjohnson Apr 25, 2026
c5cf2dd
ENH: Per-commit pre-commit replay for remote-module ingestion
hjmjohnson Apr 27, 2026
45eece3
COMP: Drop standalone-build boilerplate from GenericLabelInterpolator
hjmjohnson Apr 27, 2026
6c87ea0
DOC: Note post-merge autosquash hazard in ingestion rules
hjmjohnson Apr 27, 2026
957dae2
DOC: Demand the root-commit ghostflow error for ingest PRs
hjmjohnson Apr 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Modules/Filtering/GenericLabelInterpolator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
itk_module_impl()
65 changes: 65 additions & 0 deletions Modules/Filtering/GenericLabelInterpolator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# GenericLabelInterpolator

In-tree ITK module providing a generic interpolator for multi-label
images. `itk::LabelImageGenericInterpolateImageFunction` interpolates
each label independently with any ordinary image interpolator and
returns, at each query point, the label whose interpolated value is
highest. Generalizes the Gaussian-only behavior of
`itk::LabelImageGaussianInterpolateImageFunction`.

## Origin

Ingested from the standalone remote module
[**InsightSoftwareConsortium/ITKGenericLabelInterpolator**](https://github.com/InsightSoftwareConsortium/ITKGenericLabelInterpolator)
on 2026-04-25, at upstream commit
[`081575cd`](https://github.com/InsightSoftwareConsortium/ITKGenericLabelInterpolator/commit/081575cdcc26b1a542d4c90feaf9250df5e104d9).
The upstream repository will be archived read-only after this PR
merges; it remains reachable at the URL above.

## What lives here

Per the v3 ingestion strategy (see
`Utilities/Maintenance/RemoteModuleIngest/INGESTION_STRATEGY.md`), only
paths matching the narrow whitelist (code, headers, tests, wrapping,
module CMake) crossed the merge boundary:

- `include/` — public C++ headers.
- `test/` — CTest drivers and content-link stubs.
- `wrapping/` — Python wrapping descriptors.
- `CMakeLists.txt`, `itk-module.cmake` — build + module descriptors.

Every surviving commit preserves original authorship; `git blame`
walks across the merge boundary to upstream authors back to 2014.

## What was intentionally left upstream

Everything outside the whitelist stays in the archived upstream repo.
If you need any of it, clone
<https://github.com/InsightSoftwareConsortium/ITKGenericLabelInterpolator>.

| Content in upstream | Why it did not ingest |
|---|---|
| `examples/` | Per-module `examples/` are routed to top-level [`Examples/`](https://github.com/InsightSoftwareConsortium/ITK/tree/main/Examples) via a separate follow-up PR. |
| `README.rst` | Algorithm citations + background are folded into the Doxygen on the filter headers and the module DESCRIPTION. |
| `.github/`, `azure-pipelines.yml`, `Dockerfile` | Standalone-build CI scaffolding; not useful in-tree. |
| `CTestConfig.cmake`, `pyproject.toml`, `LICENSE`, `.clang-format` | Packaging / CI / style scaffolding superseded by ITK root. |

## Long-form documentation

- **Algorithm description** — see the Doxygen on
`itkLabelImageGenericInterpolateImageFunction`, plus the embedded
citation:

> Schaerer, J., Roche, F., Belaroussi, B.
> *A generic interpolator for multi-label images*.
> The Insight Journal, January–December 2014.
> <https://hdl.handle.net/10380/3506>

- **Standalone build + usage examples** — see the archived upstream at
<https://github.com/InsightSoftwareConsortium/ITKGenericLabelInterpolator>.

## Content-link status

The 2 baseline / input content-links under `test/Baseline/` and
`test/Input/` are already in `.cid` (IPFS Content Identifier) form;
no `.md5` → `.cid` normalization is required for this module.
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkLabelImageGenericInterpolateImageFunction_h
#define itkLabelImageGenericInterpolateImageFunction_h

#include <itkInterpolateImageFunction.h>
#include "itkLabelSelectionImageAdaptor.h"
#include <vector>
#include <set>

namespace itk
{

/** \class LabelImageGenericInterpolateImageFunction
* \brief Interpolation function for multi-label images that implicitly interpolates each
* unique value in the image corresponding to each label set element and returns the
* corresponding label set element with the largest weight.
*
* This filter is an alternative to nearest neighbor interpolation for multi-label
* images. It can use almost any underlying interpolator.
* * \ingroup ITKImageFunction
* * \ingroup GenericLabelInterpolator
*/

template <typename TInputImage,
template <typename TInterpInputImage, typename TCoordRep> class TInterpolator,
typename TCoordRep = double>
class ITK_EXPORT LabelImageGenericInterpolateImageFunction : public InterpolateImageFunction<TInputImage, TCoordRep>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(LabelImageGenericInterpolateImageFunction);

/** Standard class type alias. */
using Self = LabelImageGenericInterpolateImageFunction;
using Superclass = InterpolateImageFunction<TInputImage, TCoordRep>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
using InputPixelType = typename TInputImage::PixelType;

/** Run-time type information (and related methods). */
itkOverrideGetNameOfClassMacro(LabelImageGenericInterpolateImageFunction);

/** Method for creation through the object factory. */
itkNewMacro(Self);

/** ImageDimension constant */
static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;

/** OutputType type alias support. */
using OutputType = typename Superclass::OutputType;

/** InputImageType type alias support. */
using InputImageType = typename Superclass::InputImageType;

/** RealType type alias support. */
using RealType = typename Superclass::RealType;

/** Index type alias support. */
using IndexType = typename Superclass::IndexType;

/** Size type alias support. */
using SizeType = typename Superclass::SizeType;

/** ContinuousIndex type alias support. */
using ContinuousIndexType = typename Superclass::ContinuousIndexType;

using LabelSelectionAdaptorType = LabelSelectionImageAdaptor<TInputImage, double>;

// The interpolator used for individual binary masks corresponding to each label
using InternalInterpolatorType = TInterpolator<LabelSelectionAdaptorType, TCoordRep>;

/**
* Evaluate at the given index
*/
OutputType
EvaluateAtContinuousIndex(const ContinuousIndexType & cindex) const override
{
return this->EvaluateAtContinuousIndex(cindex, nullptr);
}

void
SetInputImage(const TInputImage * image) override;

/** Get the radius required for interpolation.
*
* This defines the number of surrounding pixels required to interpolate at
* a given point.
*/
SizeType
GetRadius() const override
{
return SizeType::Filled(1);
}

protected:
LabelImageGenericInterpolateImageFunction() = default;
~LabelImageGenericInterpolateImageFunction() override = default;

std::vector<typename InternalInterpolatorType::Pointer> m_InternalInterpolators;
std::vector<typename LabelSelectionAdaptorType::Pointer> m_LabelSelectionAdaptors;
using LabelSetType = std::set<typename TInputImage::PixelType>;
LabelSetType m_Labels;

private:
/**
* Evaluate function value at the given index
*/
virtual OutputType
EvaluateAtContinuousIndex(const ContinuousIndexType &, OutputType *) const;
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
# include "itkLabelImageGenericInterpolateImageFunction.hxx"
#endif

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkLabelImageGenericInterpolateImageFunction_hxx
#define itkLabelImageGenericInterpolateImageFunction_hxx

#include <itkImageRegionConstIterator.h>

namespace itk
{

template <typename TInputImage,
template <typename TInterpInputImage, typename TCoordRep> class TInterpolator,
typename TCoordRep>
void
LabelImageGenericInterpolateImageFunction<TInputImage, TInterpolator, TCoordRep>::SetInputImage(
const TInputImage * image)
{
/* We have one adaptor and one interpolator per label to keep the class thread-safe:
* changing the adaptor's accepted value wouldn't work when called from a multi-threaded filter */
using IteratorType = itk::ImageRegionConstIterator<TInputImage>;
if (image)
{
m_Labels.clear();
IteratorType it(image, image->GetLargestPossibleRegion());
for (it.GoToBegin(); !it.IsAtEnd(); ++it)
{
m_Labels.insert(it.Get());
}
m_InternalInterpolators.clear();
m_LabelSelectionAdaptors.clear();
for (auto i = m_Labels.begin(); i != m_Labels.end(); ++i)
{
typename LabelSelectionAdaptorType::Pointer adapt = LabelSelectionAdaptorType::New();
// This adaptor doesn't implement Set() so this should be safe
adapt->SetImage(const_cast<TInputImage *>(image));
adapt->SetAcceptedValue(*i);
m_LabelSelectionAdaptors.push_back(adapt);
typename InternalInterpolatorType::Pointer interp = InternalInterpolatorType::New();
interp->SetInputImage(adapt);
m_InternalInterpolators.push_back(interp);
Comment thread
hjmjohnson marked this conversation as resolved.
}
}
Superclass::SetInputImage(image);
}

template <typename TInputImage,
template <typename TInterpInputImage, typename TCoordRep> class TInterpolator,
typename TCoordRep>
typename LabelImageGenericInterpolateImageFunction<TInputImage, TInterpolator, TCoordRep>::OutputType
LabelImageGenericInterpolateImageFunction<TInputImage, TInterpolator, TCoordRep>::EvaluateAtContinuousIndex(
const ContinuousIndexType & cindex,
OutputType * itkNotUsed(grad)) const
{
/* Interpolate the binary mask corresponding to each label and return the label
* with the highest value */
double value = 0;
InputPixelType best_label = itk::NumericTraits<InputPixelType>::ZeroValue();
int i = 0;
for (auto it = m_Labels.begin(); it != m_Labels.end(); ++it)
{
double tmp = m_InternalInterpolators[i]->EvaluateAtContinuousIndex(cindex);
if (tmp > value)
{
value = tmp;
best_label = (*it);
}
++i;
}
return best_label;
}

} // namespace itk

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkLabelSelectionImageAdaptor_h
#define itkLabelSelectionImageAdaptor_h

#include "itkLabelSelectionPixelAccessor.h"

namespace itk
{
/** \class LabelSelectionImageAdaptor
* \brief Presents a label image as a binary image of one label
*
* Additional casting is performed according to the input and output image
* types following C++ default casting rules.
*
* \ingroup ImageAdaptors
* \ingroup ITKImageAdaptors
* \ingroup GenericLabelInterpolator
*/
template <class TImage, class TOutputPixelType>
class ITK_EXPORT LabelSelectionImageAdaptor
: public ImageAdaptor<TImage, Accessor::LabelSelectionPixelAccessor<typename TImage::PixelType, TOutputPixelType>>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(LabelSelectionImageAdaptor);

/** Standard class type alias. */
using Self = LabelSelectionImageAdaptor;
using Superclass =
ImageAdaptor<TImage, Accessor::LabelSelectionPixelAccessor<typename TImage::PixelType, TOutputPixelType>>;

using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

/** Method for creation through the object factory. */
itkNewMacro(Self);

/** Run-time type information (and related methods). */
itkOverrideGetNameOfClassMacro(LabelSelectionImageAdaptor);

void
SetAcceptedValue(typename TImage::PixelType value)
{
this->GetPixelAccessor().SetAcceptedValue(value);
}

protected:
LabelSelectionImageAdaptor() = default;
~LabelSelectionImageAdaptor() override = default;
};
} // end namespace itk

#endif
Loading
Loading