-
-
Notifications
You must be signed in to change notification settings - Fork 726
ENH: Ingest ITKFastBilateral into Modules/Filtering (supersedes #5134) #6159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hjmjohnson
merged 20 commits into
InsightSoftwareConsortium:main
from
hjmjohnson:ingest-FastBilateral
Apr 29, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5501978
ENH: Create external module from the InsightJournal publication 692
phcerdan 42d8980
Add all the tests from the Insight Journal
phcerdan a66f092
ENH: Test creating a filter instance from python
phcerdan bcadf7a
COMP: Remove inclusion of .hxx files as headers
phcerdan f17286c
STYLE: Pass style tests
dzenanz dfc2a9a
STYLE: Apply clang-format
dzenanz 5fbe87b
COMP: Fix clang compile warnings about missing override specifier
dzenanz 0324086
Merge pull request #4 from InsightSoftwareConsortium/update
dzenanz c0192e3
STYLE: Add itkVirtualGetNameOfClassMacro + itkOverrideGetNameOfClassM…
hjmjohnson 7b8adbc
STYLE: Replace itkStaticConstMacro with static constexpr
hjmjohnson cf712aa
COMP: Replace SetUseImageSpacingOff -> UseImageSpacingOff
hjmjohnson 8ab35e9
STYLE: Replace 'typedefs' with 'type aliases' in comments
hjmjohnson fb7413f
ENH: Convert from md5 to .cid tags.
hjmjohnson 111f40f
ENH: Ingest ITKFastBilateral into Modules/Filtering
hjmjohnson 5544e52
COMP: Drop standalone-build boilerplate from FastBilateral
hjmjohnson 325fe1e
COMP: Remove FastBilateral.remote.cmake; now in-tree
hjmjohnson dda62df
ENH: Enable FastBilateral in CI via configure-ci
hjmjohnson ff6ae1c
COMP: Drop missing README.rst read in ingested FastBilateral
hjmjohnson dd21525
STYLE: Apply gersemi and end-of-file-fixer to ingested FastBilateral
hjmjohnson d3a0668
STYLE: Address greptile review feedback on ingested FastBilateral
hjmjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| itk_module_impl() |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # FastBilateral | ||
|
|
||
| In-tree ITK module providing | ||
| `itk::FastBilateralImageFilter`, a fast approximation to the bilateral | ||
| filter that performs edge-preserving smoothing by accumulating samples | ||
| into a low-resolution intensity-spatial bilateral grid and then | ||
| interpolating back to the input grid. The approximation reduces the | ||
| asymptotic cost from `O(N * sigma_s^d * sigma_r)` for the brute-force | ||
| bilateral filter to roughly `O(N + L)` where `L` is the size of the | ||
| downsampled grid, making it tractable for 3D volumes. | ||
|
|
||
| ## Origin | ||
|
|
||
| Ingested from the standalone remote module | ||
| [**InsightSoftwareConsortium/ITKFastBilateral**](https://github.com/InsightSoftwareConsortium/ITKFastBilateral) | ||
| on 2026-04-28, at upstream tag | ||
| [`v1.0.1`](https://github.com/InsightSoftwareConsortium/ITKFastBilateral/releases/tag/v1.0.1) | ||
| (commit `54931e8c`). The upstream repository will be archived read-only | ||
| after this PR merges; it remains reachable at the URL above. | ||
|
|
||
| ## What lives here | ||
|
|
||
| - `include/itkFastBilateralImageFilter.h` — the templated filter. | ||
| - `include/itkFastBilateralImageFilter.hxx` — implementation. | ||
| - `test/` — three regression tests (Gaussian comparison, Insight Journal | ||
| cake/cake_easy fixtures) plus their CID-addressed baselines. | ||
| - `wrapping/` — Python wrapping declarations. | ||
|
|
||
| ## Reference | ||
|
|
||
| - Sylvain Paris and Frédo Durand, *A Fast Approximation of the Bilateral | ||
| Filter using a Signal Processing Approach*, MIT CSAIL TR 2006-073 / | ||
| ECCV 2006. The Insight Journal write-up that this module is derived | ||
| from is at https://doi.org/10.54294/noo5vc. |
197 changes: 197 additions & 0 deletions
197
Modules/Filtering/FastBilateral/include/itkFastBilateralImageFilter.h
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| /*========================================================================= | ||
| * | ||
| * 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 itkFastBilateralImageFilter_h | ||
| #define itkFastBilateralImageFilter_h | ||
|
|
||
| #include "itkImageToImageFilter.h" | ||
| #include "itkImage.h" | ||
| #include "itkDiscreteGaussianImageFilter.h" | ||
| #include "itkImageRegionIterator.h" | ||
| #include "itkImageRegionConstIteratorWithIndex.h" | ||
| #include "itkLinearInterpolateImageFunction.h" | ||
|
|
||
| namespace itk | ||
| { | ||
| /** | ||
| * \class FastBilateralImageFilter | ||
| * \brief A fast approximation to the bilateral filter | ||
| * \ingroup FastBilateral | ||
| * | ||
| * This filter is a fast approximation to the bilateral filter. | ||
| * Blurring is performed on an image based on the distance of pixels in | ||
| * both space and intensity. | ||
| * | ||
| * The algorithm used was originally proposed by Paris and | ||
| * Durand [1]. | ||
| * | ||
| * Instead of calculating a kernel for every pixel in | ||
| * an image, this filter places the values of each pixel into a higher | ||
| * dimensional image determined by the position and intensity of a pixel. | ||
| * How many bins are used is determined by the sigma values provided | ||
| * to the filter. Larger sigmas will result in more aggresive downsampling | ||
| * and less running time overall. After the data of an image | ||
| * has been organized into bins, a DiscreteGaussianImageFilter is applied. | ||
| * Finally, the output image is constructed by interpolating the | ||
| * values of the output pixels from the blurred higher | ||
| * dimensional image. | ||
| * | ||
| * [1] Sylvain Paris and Frédo Durand, | ||
| * A Fast Approximation of the Bilateral Filter using a Signal Processing | ||
| * Approach, | ||
| * European Conference on Computer Vision (ECCV'06) | ||
| * | ||
| * \sa BilateralImageFilter | ||
| * \sa GaussianOperator | ||
| * \sa AnisotropicDiffusionImageFilter | ||
| * \sa Image | ||
| * \sa Neighborhood | ||
| * \sa NeighborhoodOperator | ||
| * | ||
| * \ingroup ImageEnhancement | ||
| * \ingroup ImageFeatureExtraction | ||
| * | ||
| * \todo Support for color images | ||
| * \todo Support for vector images | ||
| */ | ||
|
|
||
| template <typename TInputImage, typename TOutputImage> | ||
| class ITK_EXPORT FastBilateralImageFilter : public ImageToImageFilter<TInputImage, TOutputImage> | ||
| { | ||
| public: | ||
| ITK_DISALLOW_COPY_AND_MOVE(FastBilateralImageFilter); | ||
|
|
||
| /** Standard class type aliases. */ | ||
| using Self = FastBilateralImageFilter; | ||
| using Superclass = ImageToImageFilter<TInputImage, TOutputImage>; | ||
| 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(FastBilateralImageFilter); | ||
|
|
||
| /** Dimensionality of the input image. Dimensionality of the output image | ||
| * is assumed to be the same. */ | ||
| static constexpr unsigned int ImageDimension = TInputImage::ImageDimension; | ||
|
|
||
| /** Input image type aliases. */ | ||
| using InputImageType = TInputImage; | ||
| using InputImagePointer = typename TInputImage::Pointer; | ||
| using InputImageConstPointer = typename TInputImage::ConstPointer; | ||
| using InputImageSpacingType = typename TInputImage::SpacingType; | ||
| using InputImageSizeType = typename TInputImage::SizeType; | ||
| using InputImageIndexType = typename TInputImage::IndexType; | ||
|
|
||
| /** Input image iterator type. */ | ||
| using InputImageConstIteratorType = ImageRegionConstIteratorWithIndex<TInputImage>; | ||
|
|
||
| /** Output image type aliases. */ | ||
| using OutputImageType = TOutputImage; | ||
| using OutputImagePointer = typename TOutputImage::Pointer; | ||
|
|
||
| /** Output image iterator type. */ | ||
| using OutputImageIteratorType = ImageRegionIterator<TOutputImage>; | ||
|
|
||
| /** Pixel types. */ | ||
| using OutputPixelType = typename TOutputImage::PixelType; | ||
| using InputPixelType = typename TInputImage::PixelType; | ||
|
|
||
| /** Typedef for an array of doubles that specifies the DomainSigma | ||
| * in each spacial dimension. */ | ||
| using DomainSigmaArrayType = FixedArray<double, Self::ImageDimension>; | ||
|
|
||
| /** Standard get/set macros for filter parameters. | ||
| * DomainSigma is specified in the same units as the Image spacing. | ||
| * RangeSigma is specified in the units of intensity. */ | ||
| itkGetConstMacro(DomainSigma, DomainSigmaArrayType); | ||
| itkSetMacro(DomainSigma, DomainSigmaArrayType); | ||
| itkGetConstMacro(RangeSigma, double); | ||
| itkSetMacro(RangeSigma, double); | ||
|
|
||
| /** Convenience set method for setting all domain standard deviations to the | ||
| * same value. */ | ||
| void | ||
| SetDomainSigma(const double v) | ||
| { | ||
| m_DomainSigma.Fill(v); | ||
| } | ||
|
|
||
| protected: | ||
| /** Default Constructor. Default value for DomainSigma is 4. Default | ||
| * value for RangeSigma is 50. These values were chosen match those of the | ||
| * BilateralImageFilter */ | ||
| FastBilateralImageFilter() | ||
| { | ||
| m_DomainSigma.Fill(4.0); | ||
| m_RangeSigma = 50.0; | ||
| } | ||
|
|
||
| ~FastBilateralImageFilter() override = default; | ||
|
|
||
| /* | ||
| * The FastBilateralImageFilter needs a larger input requested | ||
| * region than the size of the output requested region. Like | ||
| * the BilateralImageFilter, the FastBilateralImageFilter needs | ||
| * an amount of padding in each dimension based on the domain sigma. | ||
| */ | ||
| void | ||
| GenerateInputRequestedRegion() override; | ||
|
|
||
| /** Standard pipline method */ | ||
| void | ||
| GenerateData() override; | ||
|
|
||
| /** Method to print member variables to an output stream */ | ||
| void | ||
| PrintSelf(std::ostream & os, Indent indent) const override; | ||
|
|
||
| /** The type of image to use as the higher dimensional grid. | ||
| * The blurring is performed on this image type. */ | ||
| using GridType = typename itk::Image<float, Self::ImageDimension + 1>; | ||
|
|
||
| /** Grid types */ | ||
| using GridPixelType = typename GridType::PixelType; | ||
| using GridIndexType = typename GridType::IndexType; | ||
| using GridSizeType = typename GridType::SizeType; | ||
| using GridSizeValueType = typename Size<Self::ImageDimension + 1>::SizeValueType; | ||
| using GridRegionType = typename GridType::RegionType; | ||
|
|
||
| /** Grid image iterator type. */ | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| using GridImageIteratorType = ImageRegionIterator<GridType>; | ||
| using GridImageConstIteratorType = ImageRegionConstIterator<GridType>; | ||
|
|
||
| /** The type of blurring to use on the grid. */ | ||
| using BlurType = DiscreteGaussianImageFilter<GridType, GridType>; | ||
|
|
||
| /** The type of interpolation done to calculate output pixels. */ | ||
| using InterpolatorType = LinearInterpolateImageFunction<GridType, float>; | ||
| using InterpolatedIndexType = typename InterpolatorType::ContinuousIndexType; | ||
|
|
||
| double m_RangeSigma; | ||
| DomainSigmaArrayType m_DomainSigma; | ||
| }; | ||
|
|
||
| } // namespace itk | ||
|
|
||
| #ifndef ITK_MANUAL_INSTANTIATION | ||
| # include "itkFastBilateralImageFilter.hxx" | ||
| #endif | ||
|
|
||
| #endif // itkFastBilateralImageFilter | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.