[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
Generic 1 dimensional convolution kernel. More...
#include <vigra/separableconvolution.hxx>
Generic 1 dimensional convolution kernel.
This kernel may be used for convolution of 1 dimensional signals or for separable convolution of multidimensional signals.
Convolution functions access the kernel via a 1 dimensional random access iterator which they get by calling center(). This iterator points to the center of the kernel. The kernel's size is given by its left() (<=0) and right() (>= 0) methods. The desired border treatment mode is returned by borderTreatment().
The different init functions create a kernel with the specified properties. The kernel's value_type must be a linear space, i.e. it must define multiplication with doubles and NumericTraits.
Usage:
#include <vigra/separableconvolution.hxx>
Namespace: vigra
typedef InternalVector::value_type value_type |
the kernel's value type
the kernel's reference type
the kernel's const reference type
deprecated – use Kernel1D::iterator
1D random access iterator over the kernel's values
const 1D random access iterator over the kernel's values
the kernel's accessor
the kernel's const accessor
Default constructor. Creates a kernel of size 1 which would copy the signal unchanged.
Construct from kernel with different element type, e.g. double => FixedPoint16.
Copy assignment.
InitProxy operator= | ( | value_type const & | v | ) |
Initialization. This initializes the kernel with the given constant. The norm becomes v*size().
Instead of a single value an initializer list of length size() can be used like this:
In this case, the norm will be set to the sum of the init values. An initializer list of wrong length will result in a run-time error.
void initGaussian | ( | double | std_dev, |
value_type | norm, | ||
double | windowRatio = 0.0 |
||
) |
Init as a sampled Gaussian function. The radius of the kernel is always 3*std_dev. 'norm
' denotes the sum of all bins of the kernel (i.e. the kernel is corrected for the normalization error introduced by windowing the Gaussian to a finite interval). However, if norm
is 0.0, the kernel is normalized to 1 by the analytic expression for the Gaussian, and no correction for the windowing error is performed. If windowRatio = 0.0
, the radius of the filter window is radius = round(3.0 * std_dev)
, otherwise it is radius = round(windowRatio * std_dev)
(where windowRatio > 0.0
is required).
Precondition:
Postconditions:
Init as a Gaussian function with norm 1.
void initDiscreteGaussian | ( | double | std_dev, |
value_type | norm | ||
) |
Init as a Lindeberg's discrete analog of the Gaussian function with norm 1.
void initGaussianDerivative | ( | double | std_dev, |
int | order, | ||
value_type | norm, | ||
double | windowRatio = 0.0 |
||
) |
Init as a Gaussian derivative of order 'order
'. The radius of the kernel is always 3*std_dev + 0.5*order
. 'norm
' denotes the norm of the kernel so that the following condition is fulfilled:
Thus, the kernel will be corrected for the error introduced by windowing the Gaussian to a finite interval. However, if norm
is 0.0, the kernel is normalized to 1 by the analytic expression for the Gaussian derivative, and no correction for the windowing error is performed. If windowRatio = 0.0
, the radius of the filter window is radius = round(3.0 * std_dev + 0.5 * order)
, otherwise it is radius = round(windowRatio * std_dev)
(where windowRatio > 0.0
is required).
Preconditions:
Postconditions:
Init as a Gaussian derivative with norm 1.
Init an optimal 3-tap smoothing filter. The filter values are
These values are optimal in the sense that the 3x3 filter obtained by separable application of this filter is the best possible 3x3 approximation to a Gaussian filter. The equivalent Gaussian has sigma = 0.680.
Postconditions:
Init an optimal 3-tap smoothing filter to be used in the context of first derivative computation. This filter must be used in conjunction with the symmetric difference filter (see initSymmetricDifference()), such that the difference filter is applied along one dimension, and the smoothing filter along the other. The filter values are
These values are optimal in the sense that the 3x3 filter obtained by combining this filter with the symmetric difference is the best possible 3x3 approximation to a Gaussian first derivative filter. The equivalent Gaussian has sigma = 0.675.
Postconditions:
Init an optimal 3-tap smoothing filter to be used in the context of second derivative computation. This filter must be used in conjunction with the 3-tap second difference filter (see initSecondDifference3()), such that the difference filter is applied along one dimension, and the smoothing filter along the other. The filter values are
These values are optimal in the sense that the 3x3 filter obtained by combining this filter with the 3-tap second difference is the best possible 3x3 approximation to a Gaussian second derivative filter. The equivalent Gaussian has sigma = 0.433.
Postconditions:
Init an optimal 5-tap smoothing filter. The filter values are
These values are optimal in the sense that the 5x5 filter obtained by separable application of this filter is the best possible 5x5 approximation to a Gaussian filter. The equivalent Gaussian has sigma = 0.867.
Postconditions:
Init an optimal 5-tap smoothing filter to be used in the context of first derivative computation. This filter must be used in conjunction with the optimal 5-tap first derivative filter (see initOptimalFirstDerivative5()), such that the derivative filter is applied along one dimension, and the smoothing filter along the other. The filter values are
These values are optimal in the sense that the 5x5 filter obtained by combining this filter with the optimal 5-tap first derivative is the best possible 5x5 approximation to a Gaussian first derivative filter. The equivalent Gaussian has sigma = 0.906.
Postconditions:
Init an optimal 5-tap smoothing filter to be used in the context of second derivative computation. This filter must be used in conjunction with the optimal 5-tap second derivative filter (see initOptimalSecondDerivative5()), such that the derivative filter is applied along one dimension, and the smoothing filter along the other. The filter values are
These values are optimal in the sense that the 5x5 filter obtained by combining this filter with the optimal 5-tap second derivative is the best possible 5x5 approximation to a Gaussian second derivative filter. The equivalent Gaussian has sigma = 0.817.
Postconditions:
Init a 5-tap filter as defined by Peter Burt in the context of pyramid creation. The filter values are
The default a = 0.04785
is optimal in the sense that it minimizes the difference to a true Gaussian filter (which would have sigma = 0.975). For other values of a
, the scale of the most similar Gaussian can be approximated by
Preconditions:
Postconditions:
void initBinomial | ( | int | radius, |
value_type | norm | ||
) |
Init as a Binomial filter. 'norm' denotes the sum of all bins of the kernel.
Precondition:
Postconditions:
Init as a Binomial filter with norm 1.
void initAveraging | ( | int | radius, |
value_type | norm | ||
) |
Init as an Averaging filter. 'norm' denotes the sum of all bins of the kernel. The window size is (2*radius+1) * (2*radius+1)
Precondition:
Postconditions:
Init as an Averaging filter with norm 1.
void initSymmetricGradient | ( | value_type | norm | ) |
Init as a symmetric gradient filter of the form [ 0.5 * norm, 0.0 * norm, -0.5 * norm]
Deprecated. Use initSymmetricDifference() instead.
Postconditions:
Init as a symmetric gradient filter with norm 1.
Deprecated. Use initSymmetricDifference() instead.
Init as the 2-tap forward difference filter. The filter values are
(note that filters are reflected by the convolution algorithm, and we get a forward difference after reflection).
Postconditions:
Init as the 2-tap backward difference filter. The filter values are
(note that filters are reflected by the convolution algorithm, and we get a forward difference after reflection).
Postconditions:
Init as the 3-tap symmetric difference filter The filter values are
Postconditions:
Init the 3-tap second difference filter. The filter values are
Postconditions:
Init an optimal 5-tap first derivative filter. This filter must be used in conjunction with the corresponding 5-tap smoothing filter (see initOptimalFirstDerivativeSmoothing5()), such that the derivative filter is applied along one dimension, and the smoothing filter along the other. The filter values are
These values are optimal in the sense that the 5x5 filter obtained by combining this filter with the corresponding 5-tap smoothing filter is the best possible 5x5 approximation to a Gaussian first derivative filter. The equivalent Gaussian has sigma = 0.906.
If the filter is instead separably combined with itself, an almost optimal approximation of the mixed second Gaussian derivative at scale sigma = 0.899 results.
Postconditions:
Init an optimal 5-tap second derivative filter. This filter must be used in conjunction with the corresponding 5-tap smoothing filter (see initOptimalSecondDerivativeSmoothing5()), such that the derivative filter is applied along one dimension, and the smoothing filter along the other. The filter values are
These values are optimal in the sense that the 5x5 filter obtained by combining this filter with the corresponding 5-tap smoothing filter is the best possible 5x5 approximation to a Gaussian second derivative filter. The equivalent Gaussian has sigma = 0.817.
Postconditions:
Init the kernel by an explicit initializer list. The left and right boundaries of the kernel must be passed. A comma-separated initializer list is given after the assignment operator. This function is used like this:
The norm is set to the sum of the initializer values. If the wrong number of values is given, a run-time error results. It is, however, possible to give just one initializer. This creates an averaging filter with the given constant:
Here, the norm is set to value*size().
Preconditions:
left border of kernel (inclusive), always <= 0
right border of kernel (inclusive), always >= 0
current border treatment mode
Set border treatment mode.
value_type norm | ( | ) | const |
norm of kernel
void normalize | ( | value_type | norm, |
unsigned int | derivativeOrder = 0 , |
||
double | offset = 0.0 |
||
) |
set a new norm and normalize kernel, use the normalization formula for the given derivativeOrder
.
ConstAccessor accessor | ( | ) | const |
get a const accessor
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |