Create Gaussian Kernel¶
Synopsis¶
Create a Gaussian kernel.
Results¶
Output:
Size: [3, 3]
Neighborhood:
Radius:[1, 1]
Size:[3, 3]
DataBuffer:NeighborhoodAllocator { this = 0x7ffee598a9d8, begin = 0x7f7f502572a0, size=9 }
[1, 1] 0
[0, 1] 0
[1, 1] 0
[1, 0] 0.208375
[0, 0] 0.466801
[1, 0] 0.208375
[1, 1] 0
[0, 1] 0
[1, 1] 0
Code¶
C++¶
#include <itkGaussianOperator.h>
int
main(int, char *[])
{
using GaussianOperatorType = itk::GaussianOperator<float, 2>;
GaussianOperatorType gaussianOperator;
gaussianOperator.SetDirection(0); // Create the operator for the X axis derivative
itk::Size<2> radius;
radius.Fill(1);
gaussianOperator.CreateToRadius(radius);
std::cout << "Size: " << gaussianOperator.GetSize() << std::endl;
std::cout << gaussianOperator << std::endl;
for (unsigned int i = 0; i < 9; i++)
{
std::cout << gaussianOperator.GetOffset(i) << " " << gaussianOperator.GetElement(i) << std::endl;
}
return EXIT_SUCCESS;
}
Python¶
#!/usr/bin/env python
import itk
gaussianOperator = itk.GaussianOperator[itk.F, 2]()
gaussianOperator.SetDirection(0) # Create the operator for the X axis derivative
radius = itk.Size[2]()
radius.Fill(1)
gaussianOperator.CreateToRadius(radius)
print("Size: " + str(gaussianOperator.GetSize()))
print(gaussianOperator)
for i in range(9):
print(str(gaussianOperator.GetOffset(i)) + " " + str(gaussianOperator.GetElement(i)))
Classes demonstrated¶

template<typename
TPixel
, unsigned intVDimension
= 2, typenameTAllocator
= NeighborhoodAllocator<TPixel>>
classGaussianOperator
: public itk::NeighborhoodOperator<TPixel, VDimension, TAllocator> A NeighborhoodOperator whose coefficients are a one dimensional, discrete Gaussian kernel.
GaussianOperator can be used to perform Gaussian blurring by taking its inner product with a Neighborhood (NeighborhoodIterator) that is swept across an image region. It is a directional operator. N successive applications oriented along each dimensional direction will effect separable, efficient, ND Gaussian blurring of an image region.
GaussianOperator takes two parameters:
(1) The floatingpoint variance of the desired Gaussian function.
(2) The “maximum error” allowed in the discrete Gaussian function. “Maximum errror” is defined as the difference between the area under the discrete Gaussian curve and the area under the continuous Gaussian. Maximum error affects the Gaussian operator size. Care should be taken not to make this value too small relative to the variance lest the operator size become unreasonably large.
References: The Gaussian kernel contained in this operator was described by Tony Lindeberg (Discrete ScaleSpace Theory and the ScaleSpace Primal Sketch. Dissertation. Royal Institute of Technology, Stockholm, Sweden. May 1991.).
 Note
GaussianOperator does not have any userdeclared “special member function”, following the C++ Rule of Zero: the compiler will generate them if necessary.
 See
NeighborhoodOperator
 See
NeighborhoodIterator
 See
Neighborhood
 ITK Sphinx Examples: