Skip to content
Merged
Show file tree
Hide file tree
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 Dec 9, 2021
42d8980
Add all the tests from the Insight Journal
phcerdan Dec 9, 2021
a66f092
ENH: Test creating a filter instance from python
phcerdan Dec 9, 2021
bcadf7a
COMP: Remove inclusion of .hxx files as headers
phcerdan Dec 18, 2021
f17286c
STYLE: Pass style tests
dzenanz Mar 19, 2024
dfc2a9a
STYLE: Apply clang-format
dzenanz Mar 19, 2024
5fbe87b
COMP: Fix clang compile warnings about missing override specifier
dzenanz Mar 19, 2024
0324086
Merge pull request #4 from InsightSoftwareConsortium/update
dzenanz Mar 19, 2024
c0192e3
STYLE: Add itkVirtualGetNameOfClassMacro + itkOverrideGetNameOfClassM…
hjmjohnson Jan 26, 2025
7b8adbc
STYLE: Replace itkStaticConstMacro with static constexpr
hjmjohnson Jan 26, 2025
cf712aa
COMP: Replace SetUseImageSpacingOff -> UseImageSpacingOff
hjmjohnson Jan 26, 2025
8ab35e9
STYLE: Replace 'typedefs' with 'type aliases' in comments
hjmjohnson Apr 14, 2026
fb7413f
ENH: Convert from md5 to .cid tags.
hjmjohnson Apr 22, 2026
111f40f
ENH: Ingest ITKFastBilateral into Modules/Filtering
hjmjohnson Apr 28, 2026
5544e52
COMP: Drop standalone-build boilerplate from FastBilateral
hjmjohnson Apr 28, 2026
325fe1e
COMP: Remove FastBilateral.remote.cmake; now in-tree
hjmjohnson Apr 28, 2026
dda62df
ENH: Enable FastBilateral in CI via configure-ci
hjmjohnson Apr 28, 2026
ff6ae1c
COMP: Drop missing README.rst read in ingested FastBilateral
hjmjohnson Apr 28, 2026
dd21525
STYLE: Apply gersemi and end-of-file-fixer to ingested FastBilateral
hjmjohnson Apr 28, 2026
d3a0668
STYLE: Address greptile review feedback on ingested FastBilateral
hjmjohnson Apr 28, 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/FastBilateral/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
itk_module_impl()
34 changes: 34 additions & 0 deletions Modules/Filtering/FastBilateral/README.md
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 Modules/Filtering/FastBilateral/include/itkFastBilateralImageFilter.h
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);
Comment thread
greptile-apps[bot] marked this conversation as resolved.

/** 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. */
Comment thread
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
Loading
Loading