[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
![]() |
Convolution filters for multi-dimensional arrays. | ![]() |
Functions | |
template<... > | |
void | convolveFFT (...) |
Convolve an array with a kernel by means of the Fourier transform. More... | |
template<... > | |
void | convolveFFTComplex (...) |
Convolve a complex-valued array by means of the Fourier transform. More... | |
template<... > | |
void | convolveFFTComplexMany (...) |
Convolve a complex-valued array with a sequence of kernels by means of the Fourier transform. More... | |
template<... > | |
void | convolveFFTMany (...) |
Convolve a real-valued array with a sequence of kernels by means of the Fourier transform. More... | |
template<... > | |
void | convolveMultiArrayOneDimension (...) |
Convolution along a single dimension of a multi-dimensional arrays. More... | |
template<... > | |
void | correlateFFT (...) |
Correlate an array with a kernel by means of the Fourier transform. More... | |
template<... > | |
void | gaussianDivergenceMultiArray (...) |
Calculate the divergence of a vector field using Gaussian derivative filters. More... | |
template<... > | |
void | gaussianGradientMultiArray (...) |
Calculate Gaussian gradient of a multi-dimensional arrays. More... | |
template<... > | |
void | gaussianSmoothMultiArray (...) |
Isotropic Gaussian smoothing of a multi-dimensional arrays. More... | |
template<... > | |
void | hessianOfGaussianMultiArray (...) |
Calculate Hessian matrix of a N-dimensional arrays using Gaussian derivative filters. More... | |
template<... > | |
void | laplacianOfGaussianMultiArray (...) |
Calculate Laplacian of a N-dimensional arrays using Gaussian derivative filters. More... | |
template<... > | |
void | separableConvolveMultiArray (...) |
Separated convolution on multi-dimensional arrays. More... | |
template<... > | |
void | structureTensorMultiArray (...) |
Calculate th structure tensor of a multi-dimensional arrays. More... | |
template<... > | |
void | symmetricGradientMultiArray (...) |
Calculate gradient of a multi-dimensional arrays using symmetric difference filters. More... | |
These functions realize a separable convolution on an arbitrary dimensional array that is specified by iterators (compatible to Multi-dimensional Array Iterators) and shape objects. It can therefore be applied to a wide range of data structures (vigra::MultiArrayView, vigra::MultiArray etc.).
void vigra::separableConvolveMultiArray | ( | ... | ) |
Separated convolution on multi-dimensional arrays.
This function computes a separated convolution on all dimensions of the given multi-dimensional array. Both source and destination arrays are represented by iterators, shape objects and accessors. The destination array is required to already have the correct size.
There are two variants of this functions: one takes a single kernel of type vigra::Kernel1D which is then applied to all dimensions, whereas the other requires an iterator referencing a sequence of vigra::Kernel1D objects, one for every dimension of the data. Then the first kernel in this sequence is applied to the innermost dimension (e.g. the x-axis of an image), while the last is applied to the outermost dimension (e.g. the z-axis in a 3D image).
This function may work in-place, which means that source.data() == dest.data()
is allowed. A full-sized internal array is only allocated if working on the destination array directly would cause round-off errors (i.e. if typeid(typename NumericTraits<T2>::RealPromote) != typeid(T2)
).
If start
and stop
have non-default values, they must represent a valid subarray of the input array. The convolution is then restricted to that subarray, and it is assumed that the output array only refers to the subarray (i.e. dest.shape() == stop - start
). Negative ROI boundaries are interpreted relative to the end of the respective dimension (i.e. if(stop[k] < 0) stop[k] += source.shape(k);
).
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx>
Namespace: vigra
void vigra::convolveMultiArrayOneDimension | ( | ... | ) |
Convolution along a single dimension of a multi-dimensional arrays.
This function computes a convolution along one dimension (specified by the parameter dim
of the given multi-dimensional array with the given kernel
. The destination array must already have the correct size.
If start
and stop
have non-default values, they must represent a valid subarray of the input array. The convolution is then restricted to that subarray, and it is assumed that the output array only refers to the subarray (i.e. dest.shape() == stop - start
). Negative ROI boundaries are interpreted relative to the end of the respective dimension (i.e. if(stop[k] < 0) stop[k] += source.shape(k);
).
This function may work in-place, which means that source.data() == dest.data()
is allowed.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx>
Namespace: vigra
void vigra::gaussianSmoothMultiArray | ( | ... | ) |
Isotropic Gaussian smoothing of a multi-dimensional arrays.
This function computes an isotropic convolution of the given N-dimensional array with a Gaussian filter at the given standard deviation sigma
. Both source and destination arrays are represented by iterators, shape objects and accessors. The destination array is required to already have the correct size. This function may work in-place, which means that source.data() == dest.data()
is allowed. It is implemented by a call to separableConvolveMultiArray() with the appropriate kernel.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameter sigma
is omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Multi-threaded execution:
Usage with anisotropic data:
void vigra::gaussianGradientMultiArray | ( | ... | ) |
Calculate Gaussian gradient of a multi-dimensional arrays.
This function computes the Gaussian gradient of the given N-dimensional array with a sequence of first-derivative-of-Gaussian filters at the given standard deviation sigma
(differentiation is applied to each dimension in turn, starting with the innermost dimension). The destination array is required to have a vector valued pixel type with as many elements as the number of dimensions. This function is implemented by calls to separableConvolveMultiArray() with the appropriate kernels.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameter sigma
is omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Usage with anisotropic data:
void vigra::symmetricGradientMultiArray | ( | ... | ) |
Calculate gradient of a multi-dimensional arrays using symmetric difference filters.
This function computes the gradient of the given N-dimensional array with a sequence of symmetric difference filters a (differentiation is applied to each dimension in turn, starting with the innermost dimension). The destination array is required to have a vector valued pixel type with as many elements as the number of dimensions. This function is implemented by calls to convolveMultiArrayOneDimension() with the symmetric difference kernel.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameter sigma
is omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Usage with anisotropic data:
void vigra::laplacianOfGaussianMultiArray | ( | ... | ) |
Calculate Laplacian of a N-dimensional arrays using Gaussian derivative filters.
This function computes the Laplacian of the given N-dimensional array with a sequence of second-derivative-of-Gaussian filters at the given standard deviation sigma
. Both source and destination arrays must have scalar value_type. This function is implemented by calls to separableConvolveMultiArray() with the appropriate kernels, followed by summation.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameter sigma
is omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Usage with anisotropic data:
void vigra::gaussianDivergenceMultiArray | ( | ... | ) |
Calculate the divergence of a vector field using Gaussian derivative filters.
This function computes the divergence of the given N-dimensional vector field with a sequence of first-derivative-of-Gaussian filters at the given standard deviation sigma
. The input vector field can either be given as a sequence of scalar array views (one for each vector field component), represented by an iterator range, or by a single vector array with the appropriate shape. This function is implemented by calls to separableConvolveMultiArray() with the suitable kernels, followed by summation.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameter sigma
is omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Usage with anisotropic data:
void vigra::hessianOfGaussianMultiArray | ( | ... | ) |
Calculate Hessian matrix of a N-dimensional arrays using Gaussian derivative filters.
This function computes the Hessian matrix the given scalar N-dimensional array with a sequence of second-derivative-of-Gaussian filters at the given standard deviation sigma
. The destination array must have a vector valued element type with N*(N+1)/2 elements (it represents the upper triangular part of the symmetric Hessian matrix, flattened row-wise). This function is implemented by calls to separableConvolveMultiArray() with the appropriate kernels.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameter sigma
is omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Usage with anisotropic data:
void vigra::structureTensorMultiArray | ( | ... | ) |
Calculate th structure tensor of a multi-dimensional arrays.
This function computes the gradient (outer product) tensor for each element of the given N-dimensional array with first-derivative-of-Gaussian filters at the given innerScale
, followed by Gaussian smoothing at outerScale
. The destination array must have a vector valued pixel type with N*(N+1)/2 elements (it represents the upper triangular part of the symmetric structure tensor matrix, flattened row-wise). If the source array is also vector valued, the resulting structure tensor is the sum of the individual tensors for each channel. This function is implemented by calls to separableConvolveMultiArray() with the appropriate kernels.
Anisotropic data should be provided with appropriate vigra::ConvolutionOptions to adjust the filter sizes for the resolution of each axis. Otherwise, the parameter opt
is optional unless the parameters innerScale
and outerScale
are both omitted.
If you pass vigra::BlockwiseConvolutionOptions instead, the algorithm will be executed in parallel on data blocks of a certain size. The block size can be customized via BlockwiseConvolutionOptions::blockShape()
, but the defaults usually work reasonably. By default, the number of threads equals the capabilities of your hardware, but you can change this via BlockwiseConvolutionOptions::numThreads()
.
Declarations:
pass arbitrary-dimensional array views:
Usage:
#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra
Usage with anisotropic data:
void vigra::convolveFFT | ( | ... | ) |
Convolve an array with a kernel by means of the Fourier transform.
Thanks to the convolution theorem of Fourier theory, a convolution in the spatial domain is equivalent to a multiplication in the frequency domain. Thus, for certain kernels (especially large, non-separable ones), it is advantageous to perform the convolution by first transforming both array and kernel to the frequency domain, multiplying the frequency representations, and transforming the result back into the spatial domain. Some kernels have a much simpler definition in the frequency domain, so that they are readily computed there directly, avoiding Fourier transformation of those kernels.
The following functions implement various variants of FFT-based convolution:
convolveFFT
, but you may provide many kernels at once (using an iterator pair specifying the kernel sequence). This has the advantage that the forward transform of the input array needs to be executed only once. convolveFFTComplex
, but you may provide many kernels at once (using an iterator pair specifying the kernel sequence). This has the advantage that the forward transform of the input array needs to be executed only once. The output arrays must have the same shape as the input arrays. In the "Many" variants of the convolution functions, the kernels must all have the same shape.
The origin of the kernel is always assumed to be in the center of the kernel array (precisely, at the point floor(kernel.shape() / 2.0)
, except when the half-space format is used, see below). The function moveDCToUpperLeft() will be called internally to align the kernel with the transformed input as appropriate.
If a real input is combined with a real kernel, the kernel is automatically assumed to be defined in the spatial domain. If a real input is combined with a complex kernel, the kernel is assumed to be defined in the Fourier domain in half-space format. If the input array is complex, a flag fourierDomainKernel
determines where the kernel is defined.
When the kernel is defined in the spatial domain, the convolution functions will automatically pad (enlarge) the input array by at least the kernel radius in each direction. The newly added space is filled according to reflective boundary conditions in order to minimize border artifacts during convolution. It is thus ensured that convolution in the Fourier domain yields the same results as convolution in the spatial domain (e.g. when separableConvolveMultiArray() is called with the same kernel). A little further padding may be added to make sure that the padded array shape uses integers which have only small prime factors, because FFTW is then able to use the fastest possible algorithms. Any padding is automatically removed from the result arrays before the function returns.
When the kernel is defined in the frequency domain, it must be complex-valued, and its shape determines the shape of the Fourier representation (i.e. the input is padded according to the shape of the kernel). If we are going to perform a complex-valued convolution, the kernel must be defined for the entire frequency domain, and its shape directly determines the size of the FFT.
In contrast, a frequency domain kernel for a real-valued convolution must have symmetry properties that allow to drop half of the kernel coefficients, as in the R2C transform. That is, the kernel must have the half-space format, that is the shape returned by fftwCorrespondingShapeR2C(fourier_shape)
, where fourier_shape
is the desired logical shape of the frequency representation (and thus the size of the padded input). The origin of the kernel must be at the point (0, floor(fourier_shape[0] / 2.0), ..., floor(fourier_shape[N-1] / 2.0))
(i.e. as in a regular kernel except for the first dimension).
The Real
type in the declarations can be double
, float
, and long double
. Your program must always link against libfftw3
. If you use float
or long double
arrays, you must additionally link against libfftw3f
and libfftw3l
respectively.
The Fourier transform functions internally create FFTW plans which control the algorithm details. The plans are created with the flag FFTW_ESTIMATE
, i.e. optimal settings are guessed or read from saved "wisdom" files. If you need more control over planning, you can use the class FFTWConvolvePlan.
See also applyFourierFilter() for corresponding functionality on the basis of the old image iterator interface.
Declarations:
Real-valued convolution with kernel in the spatial domain:
Real-valued convolution with kernel in the Fourier domain (half-space format):
Series of real-valued convolutions with kernels in the spatial or Fourier domain (the kernel and out sequences must have the same length):
Complex-valued convolution (parameter fourierDomainKernel
determines if the kernel is defined in the spatial or Fourier domain):
Series of complex-valued convolutions (parameter fourierDomainKernel
determines if the kernels are defined in the spatial or Fourier domain, the kernel and out sequences must have the same length):
Usage:
#include <vigra/multi_fft.hxx>
Namespace: vigra
void vigra::convolveFFTComplex | ( | ... | ) |
Convolve a complex-valued array by means of the Fourier transform.
See convolveFFT() for details.
void vigra::convolveFFTMany | ( | ... | ) |
Convolve a real-valued array with a sequence of kernels by means of the Fourier transform.
See convolveFFT() for details.
void vigra::convolveFFTComplexMany | ( | ... | ) |
Convolve a complex-valued array with a sequence of kernels by means of the Fourier transform.
See convolveFFT() for details.
void vigra::correlateFFT | ( | ... | ) |
Correlate an array with a kernel by means of the Fourier transform.
This function correlates a real-valued input array with a real-valued kernel such that the result is also real-valued. Thanks to the correlation theorem of Fourier theory, a correlation in the spatial domain is equivalent to a multiplication with the complex conjugate in the frequency domain. Thus, for certain kernels (especially large, non-separable ones), it is advantageous to perform the correlation by first transforming both array and kernel to the frequency domain, multiplying the frequency representations, and transforming the result back into the spatial domain.
The output arrays must have the same shape as the input arrays.
See also convolveFFT() for corresponding functionality.
Declarations:
Usage:
#include <vigra/multi_fft.hxx>
Namespace: vigra
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|