vigra - Convolution filters for multi-dimensional arrays.

[ 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...

## Detailed Description

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.).

## Function Documentation

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:

namespace vigra {
// apply each kernel from the sequence 'kernels' in turn
template <unsigned int N, class T1, class S1,
class T2, class S2,
class KernelIterator>
void
separableConvolveMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
KernelIterator kernels,
typename MultiArrayShape<N>::type start = typename MultiArrayShape<N>::type(),
typename MultiArrayShape<N>::type stop = typename MultiArrayShape<N>::type());
// apply the same kernel to all dimensions
template <unsigned int N, class T1, class S1,
class T2, class S2,
class T>
void
separableConvolveMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
Kernel1D<T> const & kernel,
typename MultiArrayShape<N>::type const & start = typename MultiArrayShape<N>::type(),
typename MultiArrayShape<N>::type const & stop = typename MultiArrayShape<N>::type());
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
// apply the same kernel to all dimensions
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor, class T>
void
separableConvolveMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
Kernel1D<T> const & kernel,
SrcShape const & start = SrcShape(),
SrcShape const & stop = SrcShape());
// apply each kernel from the sequence 'kernels' in turn
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor, class KernelIterator>
void
separableConvolveMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
KernelIterator kernels,
SrcShape const & start = SrcShape(),
SrcShape const & stop = SrcShape());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
// apply the same kernel to all dimensions
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor, class T>
void
separableConvolveMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
Kernel1D<T> const & kernel,
SrcShape const & start = SrcShape(),
SrcShape const & stop = SrcShape());
// apply each kernel from the sequence 'kernels' in turn
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor, class KernelIterator>
void
separableConvolveMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
KernelIterator kernels,
SrcShape const & start = SrcShape(),
SrcShape const & stop = SrcShape());
}

Usage:

#include <vigra/multi_convolution.hxx>
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, float> dest(shape);
...
Kernel1D<float> gauss;
gauss.initGaussian(sigma);
// smooth all dimensions with the same kernel
separableConvolveMultiArray(source, dest, gauss);
// create 3 Gauss kernels, one for each dimension, but smooth the z-axis less
ArrayVector<Kernel1D<float> > kernels(3, gauss);
kernels[2].initGaussian(sigma / 2.0);
// perform Gaussian smoothing on all dimensions
separableConvolveMultiArray(source, dest, kernels.begin());
// create output array for a ROI
MultiArray<3, float> destROI(shape - Shape3(10,10,10));
// only smooth the given ROI (ignore 5 pixels on all sides of the array)
separableConvolveMultiArray(source, destROI, gauss, Shape3(5,5,5), Shape3(-5,-5,-5));

show deprecated examples

MultiArray<3, unsigned char>::size_type shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, float> dest(shape);
...
Kernel1D<float> gauss;
gauss.initGaussian(sigma);
// create 3 Gauss kernels, one for each dimension
ArrayVector<Kernel1D<float> > kernels(3, gauss);
// perform Gaussian smoothing on all dimensions
separableConvolveMultiArray(source, dest,
kernels.begin());

Required Interface:

see \ref separableConvolveImage(), in addition:
NumericTraits<T1>::RealPromote s = src[0];
s = s + s;
s = kernel(0) * s;

See Also
  vigra::Kernel1D, convolveLine()

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:

namespace vigra {
template <unsigned int N, class T1, class S1,
class T2, class S2,
class T>
void
convolveMultiArrayOneDimension(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
unsigned int dim,
Kernel1D<T> const & kernel,
typename MultiArrayShape<N>::type start = typename MultiArrayShape<N>::type(),
typename MultiArrayShape<N>::type stop = typename MultiArrayShape<N>::type());
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor, class T>
void
convolveMultiArrayOneDimension(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
unsigned int dim, vigra::Kernel1D<T> const & kernel,
SrcShape const & start = SrcShape(),
SrcShape const & stop = SrcShape());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor, class T>
void
convolveMultiArrayOneDimension(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
unsigned int dim, vigra::Kernel1D<T> const & kernel,
SrcShape const & start = SrcShape(),
SrcShape const & stop = SrcShape());
}

Usage:

#include <vigra/multi_convolution.hxx>
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, float> dest(shape);
...
Kernel1D<float> gauss;
gauss.initGaussian(sigma);
// perform Gaussian smoothing along dimension 1 (height)
convolveMultiArrayOneDimension(source, dest, 1, gauss);

See Also
  separableConvolveMultiArray()

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:

namespace vigra {
// pass filter scale explicitly
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianSmoothMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
double sigma,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass filer scale(s) in the option object
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianSmoothMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
ConvolutionOptions<N> opt);
// as above, but execute algorirhm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianSmoothMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
BlockwiseConvolutionOptions<N> opt);
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
gaussianSmoothMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
gaussianSmoothMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, float> dest(shape);
...
// perform isotropic Gaussian smoothing at scale 'sigma'
gaussianSmoothMultiArray(source, dest, sigma);

Multi-threaded execution:

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, float> dest(shape);
...
BlockwiseConvolutionOptions<3> opt;
opt.numThreads(4); // use 4 threads (uses hardware default if not given)
opt.innerScale(sigma);
// perform isotropic Gaussian smoothing at scale 'sigma' in parallel
gaussianSmoothMultiArray(source, dest, sigma, opt);

Usage with anisotropic data:

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, float> dest(shape);
TinyVector<float, 3> step_size;
TinyVector<float, 3> resolution_sigmas;
...
// perform anisotropic Gaussian smoothing at scale 'sigma'
gaussianSmoothMultiArray(source, dest, sigma,
ConvolutionOptions<3>().stepSize(step_size).resolutionStdDev(resolution_sigmas));

See Also
  separableConvolveMultiArray()

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:

namespace vigra {
// pass filter scale explicitly
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianGradientMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, N>, S2> dest,
double sigma,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass filter scale(s) in option object
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianGradientMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, N>, S2> dest,
ConvolutionOptions<N> opt);
// likewise, but execute algorithm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianGradientMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, N>, S2> dest,
BlockwiseConvolutionOptions<N> opt);
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
gaussianGradientMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
gaussianGradientMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, TinyVector<float, 3> > dest(shape);
...
// compute Gaussian gradient at scale sigma
gaussianGradientMultiArray(source, dest, sigma);

Usage with anisotropic data:

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, TinyVector<float, 3> > dest(shape);
TinyVector<float, 3> step_size;
TinyVector<float, 3> resolution_sigmas;
...
// compute Gaussian gradient at scale sigma
gaussianGradientMultiArray(source, dest, sigma,
ConvolutionOptions<3>().stepSize(step_size).resolutionStdDev(resolution_sigmas));

See Also
  separableConvolveMultiArray()

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:

namespace vigra {
// execute algorithm sequentially
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
symmetricGradientMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, N>, S2> dest,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// execute algorithm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
symmetricGradientMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, N>, S2> dest,
BlockwiseConvolutionOptions<N> opt);
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
symmetricGradientMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
symmetricGradientMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

MultiArray<3, unsigned char>::size_type shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, TinyVector<float, 3> > dest(shape);
...
// compute gradient
symmetricGradientMultiArray(srcMultiArrayRange(source), destMultiArray(dest));

Usage with anisotropic data:

Shape3 shape(width, height, depth);
MultiArray<3, unsigned char> source(shape);
MultiArray<3, TinyVector<float, 3> > dest(shape);
TinyVector<float, 3> step_size;
...
// compute gradient
symmetricGradientMultiArray(source, dest,
ConvolutionOptions<3>().stepSize(step_size));

See Also
  convolveMultiArrayOneDimension()

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:

namespace vigra {
// pass scale explicitly
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
laplacianOfGaussianMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
double sigma,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass scale(s) in option object
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
laplacianOfGaussianMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
ConvolutionOptions<N> opt );
// likewise, but execute algorithm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
laplacianOfGaussianMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, T2, S2> dest,
BlockwiseConvolutionOptions<N> opt );
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
laplacianOfGaussianMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
laplacianOfGaussianMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, float> source(shape);
MultiArray<3, float> laplacian(shape);
...
// compute Laplacian at scale sigma
laplacianOfGaussianMultiArray(source, laplacian, sigma);

Usage with anisotropic data:

MultiArray<3, float> source(shape);
MultiArray<3, float> laplacian(shape);
TinyVector<float, 3> step_size;
TinyVector<float, 3> resolution_sigmas;
...
// compute Laplacian at scale sigma
laplacianOfGaussianMultiArray(source, laplacian, sigma,
ConvolutionOptions<3>().stepSize(step_size).resolutionStdDev(resolution_sigmas));

See Also
  separableConvolveMultiArray()

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:

namespace vigra {
// specify input vector field as a sequence of scalar arrays
template <class Iterator,
unsigned int N, class T, class S>
void
gaussianDivergenceMultiArray(Iterator vectorField, Iterator vectorFieldEnd,
MultiArrayView<N, T, S> divergence,
ConvolutionOptions<N> const & opt);
template <class Iterator,
unsigned int N, class T, class S>
void
gaussianDivergenceMultiArray(Iterator vectorField, Iterator vectorFieldEnd,
MultiArrayView<N, T, S> divergence,
double sigma,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass input vector field as an array of vectors
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianDivergenceMultiArray(MultiArrayView<N, TinyVector<T1, N>, S1> const & vectorField,
MultiArrayView<N, T2, S2> divergence,
ConvolutionOptions<N> const & opt);
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianDivergenceMultiArray(MultiArrayView<N, TinyVector<T1, N>, S1> const & vectorField,
MultiArrayView<N, T2, S2> divergence,
double sigma,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass input vector field as an array of vectors and
// execute algorithm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
gaussianDivergenceMultiArray(MultiArrayView<N, TinyVector<T1, N>, S1> const & vectorField,
MultiArrayView<N, T2, S2> divergence,
BlockwiseConvolutionOptions<N> const & opt);
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, TinyVector<float, 3> > source(shape);
MultiArray<3, float> laplacian(shape);
...
// compute divergence at scale sigma
gaussianDivergenceMultiArray(source, laplacian, sigma);

Usage with anisotropic data:

MultiArray<3, TinyVector<float, 3> > source(shape);
MultiArray<3, float> laplacian(shape);
TinyVector<float, 3> step_size;
TinyVector<float, 3> resolution_sigmas;
...
// compute divergence at scale sigma
gaussianDivergenceMultiArray(source, laplacian, sigma,
ConvolutionOptions<3>().stepSize(step_size).resolutionStdDev(resolution_sigmas));

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:

namespace vigra {
// pass scale explicitly
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
hessianOfGaussianMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, int(N*(N+1)/2)>, S2> dest,
double sigma,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass scale(s) in option object
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
hessianOfGaussianMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, int(N*(N+1)/2)>, S2> dest,
ConvolutionOptions<N> opt);
// likewise, but execute algorithm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
hessianOfGaussianMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, int(N*(N+1)/2)>, S2> dest,
BlockwiseConvolutionOptions<N> opt);
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
hessianOfGaussianMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
hessianOfGaussianMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
double sigma,
const ConvolutionOptions<N> & opt = ConvolutionOptions<N>());
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, float> source(shape);
MultiArray<3, TinyVector<float, 6> > dest(shape);
...
// compute Hessian at scale sigma
hessianOfGaussianMultiArray(source, dest, sigma);

Usage with anisotropic data:

MultiArray<3, float> source(shape);
MultiArray<3, TinyVector<float, 6> > dest(shape);
TinyVector<float, 3> step_size;
TinyVector<float, 3> resolution_sigmas;
...
// compute Hessian at scale sigma
hessianOfGaussianMultiArray(source, dest, sigma,
ConvolutionOptions<3>().stepSize(step_size).resolutionStdDev(resolution_sigmas));

See Also
  separableConvolveMultiArray(), vectorToTensorMultiArray()

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:

namespace vigra {
// pass scales explicitly
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
structureTensorMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, int(N*(N+1)/2)>, S2> dest,
double innerScale, double outerScale,
ConvolutionOptions<N> opt = ConvolutionOptions<N>());
// pass scales in option object
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
structureTensorMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, int(N*(N+1)/2)>, S2> dest,
ConvolutionOptions<N> opt );
// likewise, but execute algorithm in parallel
template <unsigned int N, class T1, class S1,
class T2, class S2>
void
structureTensorMultiArray(MultiArrayView<N, T1, S1> const & source,
MultiArrayView<N, TinyVector<T2, int(N*(N+1)/2)>, S2> dest,
BlockwiseConvolutionOptions<N> opt );
}

show deprecated declarations

pass MultiIterators and Data Accessors :
namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
structureTensorMultiArray(SrcIterator siter, SrcShape const & shape, SrcAccessor src,
DestIterator diter, DestAccessor dest,
double innerScale, double outerScale,
ConvolutionOptions<N> opt);
}

use argument objects in conjunction with Argument Object Factories :

namespace vigra {
template <class SrcIterator, class SrcShape, class SrcAccessor,
class DestIterator, class DestAccessor>
void
structureTensorMultiArray(triple<SrcIterator, SrcShape, SrcAccessor> const & source,
pair<DestIterator, DestAccessor> const & dest,
double innerScale, double outerScale,
const ConvolutionOptions<N> & opt);
}

Usage:

#include <vigra/multi_convolution.hxx> (sequential version)
#include <vigra/multi_blockwise.hxx> (parallel version)
Namespace: vigra

Shape3 shape(width, height, depth);
MultiArray<3, RGBValue<float> > source(shape);
MultiArray<3, TinyVector<float, 6> > dest(shape);
...
// compute structure tensor at scales innerScale and outerScale
structureTensorMultiArray(source, dest, innerScale, outerScale);

Usage with anisotropic data:

MultiArray<3, RGBValue<float> > source(shape);
MultiArray<3, TinyVector<float, 6> > dest(shape);
TinyVector<float, 3> step_size;
TinyVector<float, 3> resolution_sigmas;
...
// compute structure tensor at scales innerScale and outerScale
structureTensorMultiArray(source, dest, innerScale, outerScale,
ConvolutionOptions<3>().stepSize(step_size).resolutionStdDev(resolution_sigmas));

See Also
  separableConvolveMultiArray(), vectorToTensorMultiArray()

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
  Convolve a real-valued input array with a kernel such that the result is also real-valued. That is, the kernel is either provided as a real-valued array in the spatial domain, or as a complex-valued array in the Fourier domain, using the half-space format of the R2C Fourier transform (see below).
convolveFFTMany
  Like `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
  Convolve a complex-valued input array with a complex-valued kernel, resulting in a complex-valued output array. An additional flag is used to specify whether the kernel is defined in the spatial or frequency domain.
convolveFFTComplexMany
  Like `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:

namespace vigra {
template <unsigned int N, class Real, class C1, class C2, class C3>
void
convolveFFT(MultiArrayView<N, Real, C1> in,
MultiArrayView<N, Real, C2> kernel,
MultiArrayView<N, Real, C3> out);
}

Real-valued convolution with kernel in the Fourier domain (half-space format):

namespace vigra {
template <unsigned int N, class Real, class C1, class C2, class C3>
void
convolveFFT(MultiArrayView<N, Real, C1> in,
MultiArrayView<N, FFTWComplex<Real>, C2> kernel,
MultiArrayView<N, Real, C3> out);
}

Series of real-valued convolutions with kernels in the spatial or Fourier domain (the kernel and out sequences must have the same length):

namespace vigra {
template <unsigned int N, class Real, class C1,
class KernelIterator, class OutIterator>
void
convolveFFTMany(MultiArrayView<N, Real, C1> in,
KernelIterator kernels, KernelIterator kernelsEnd,
OutIterator outs);
}

Complex-valued convolution (parameter `fourierDomainKernel` determines if the kernel is defined in the spatial or Fourier domain):

namespace vigra {
template <unsigned int N, class Real, class C1, class C2, class C3>
void
convolveFFTComplex(MultiArrayView<N, FFTWComplex<Real>, C1> in,
MultiArrayView<N, FFTWComplex<Real>, C2> kernel,
MultiArrayView<N, FFTWComplex<Real>, C3> out,
bool fourierDomainKernel);
}

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):

namespace vigra {
template <unsigned int N, class Real, class C1,
class KernelIterator, class OutIterator>
void
convolveFFTComplexMany(MultiArrayView<N, FFTWComplex<Real>, C1> in,
KernelIterator kernels, KernelIterator kernelsEnd,
OutIterator outs,
bool fourierDomainKernel);
}

Usage:

#include <vigra/multi_fft.hxx>
Namespace: vigra

// convolve real array with a Gaussian (sigma=1) defined in the spatial domain
// (implicitly uses padding by at least 4 pixels)
MultiArray<2, double> src(Shape2(w, h)), dest(Shape2(w,h));
MultiArray<2, double> spatial_kernel(Shape2(9, 9));
Gaussian<double> gauss(1.0);
for(int y=0; y<9; ++y)
for(int x=0; x<9; ++x)
spatial_kernel(x, y) = gauss(x-4.0)*gauss(y-4.0);
convolveFFT(src, spatial_kernel, dest);
// convolve real array with a Gaussian (sigma=1) defined in the Fourier domain
// (uses no padding, because the kernel size corresponds to the input size)
MultiArray<2, FFTWComplex<double> > fourier_kernel(fftwCorrespondingShapeR2C(src.shape()));
int y0 = h / 2;
for(int y=0; y<fourier_kernel.shape(1); ++y)
for(int x=0; x<fourier_kernel.shape(0); ++x)
fourier_kernel(x, y) = exp(-0.5*sq(x / double(w))) * exp(-0.5*sq((y-y0)/double(h)));
convolveFFT(src, fourier_kernel, dest);

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:

namespace vigra {
template <unsigned int N, class Real, class C1, class C2, class C3>
void
correlateFFT(MultiArrayView<N, Real, C1> in,
MultiArrayView<N, Real, C2> kernel,
MultiArrayView<N, Real, C3> out);
}

Usage:

#include <vigra/multi_fft.hxx>
Namespace: vigra

// correlate real array with a template to find best matches
// (implicitly uses padding by at least 4 pixels)
MultiArray<2, double> src(Shape2(w, h)), dest(Shape2(w, h));
MultiArray<2, double> template(Shape2(9, 9));
template = ...;
correlateFFT(src, template, dest);

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.11.0 (Thu Feb 4 2016)