[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| Kernel1D Class Template Reference |
--- | --- | ---

Generic 1 dimensional convolution kernel. More...

`#include "vigra/separableconvolution.hxx"`

## Public Types

typedef InternalVector::value_type | value_type
typedef InternalVector::reference | reference
typedef InternalVector::const_reference | const_reference
typedef InternalVector::iterator | Iterator
typedef InternalVector::iterator | iterator
typedef InternalVector::const_iterator | const_iterator
typedef StandardAccessor< ARITHTYPE > | Accessor
typedef StandardConstAccessor< ARITHTYPE > | ConstAccessor

## Public Methods

| Kernel1D ()
| Kernel1D (Kernel1D const &k)
Kernel1D & | operator= (Kernel1D const &k)
InitProxy | operator= (value_type const &v)
| ~Kernel1D ()
void | initGaussian (double std_dev, value_type norm)
void | initGaussian (double std_dev)
void | initDiscreteGaussian (double std_dev, value_type norm)
void | initDiscreteGaussian (double std_dev)
void | initGaussianDerivative (double std_dev, int order, value_type norm)
void | initGaussianDerivative (double std_dev, int order)
void | initBinomial (int radius, value_type norm)
void | initBinomial (int radius)
void | initAveraging (int radius, value_type norm)
void | initAveraging (int radius)
void | initSymmetricGradient (value_type norm)
void | initSymmetricGradient ()
Kernel1D & | initExplicitly (int left, int right)
iterator | center ()
reference | operator[] (int location)
int | left () const
int | right () const
int | size () const
BorderTreatmentMode | borderTreatment () const
void | setBorderTreatment (BorderTreatmentMode new_mode)
value_type | norm () const
void | normalize (value_type norm, unsigned int derivativeOrder=0, double offset=0.0)
void | normalize ()
ConstAccessor | accessor () const
Accessor | accessor ()

## Detailed Description

### template<class ARITHTYPE>
class vigra::Kernel1D< ARITHTYPE >

Generic 1 dimensional convolution kernel.

This kernel may be used for convolution of 1 dimensional signals or for separable convolution of multidimensional signals.

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

The kernel defines a factory function kernel1d() to create an argument object (see Kernel Argument Object Factories).

Usage:

#include "vigra/stdconvolution.hxx"

        vigra::FImage src(w,h), dest(w,h);
        ...

        // define Gaussian kernel with std. deviation 3.0
        vigra::Kernel1D kernel;
        kernel.initGaussian(3.0);

        vigra::separableConvolveX(srcImageRange(src), destImage(dest), kernel1d(kernel));

Required Interface:

        value_type v = vigra::NumericTraits<value_type>::one(); // if norm is not
                                                                // given explicitly
        double d;

        v = d * v;

Examples:

  pyramid.cxx, and smooth.cxx.

## Member Typedef Documentation

typedef StandardAccessor<ARITHTYPE> Accessor

| the kernel's accessor

typedef InternalVector::const_iterator const_iterator

| const 1D random access iterator over the kernel's values

typedef InternalVector::const_reference const_reference

| the kernel's const reference type

typedef StandardConstAccessor<ARITHTYPE> ConstAccessor

| the kernel's const accessor

typedef InternalVector::iterator iterator

| 1D random access iterator over the kernel's values

typedef InternalVector::iterator Iterator

| deprecated -- use Kernel1D::iterator

typedef InternalVector::reference reference

| the kernel's reference type

typedef InternalVector::value_type value_type

| the kernel's value type

## Constructor & Destructor Documentation

Kernel1D | ( |  | ) | `[inline]`

| Default constructor. Creates a kernel of size 1 which would copy the signal unchanged.

Kernel1D | ( | Kernel1D< ARITHTYPE > const & | k | ) | `[inline]`

| Copy constructor.

~Kernel1D | ( |  | ) | `[inline]`

| Destructor.

## Member Function Documentation

Accessor accessor | ( |  | ) | `[inline]`

| get an accessor

ConstAccessor accessor | ( |  | ) | const`[inline]`

| get a const accessor

BorderTreatmentMode borderTreatment | ( |  | ) | const`[inline]`

| current border treatment mode

iterator center | ( |  | ) | `[inline]`

Get iterator to center of kernel

Postconditions:

                center()[left()] ... center()[right()] are valid kernel positions

void initAveraging | ( | int | radius | ) | `[inline]`

| Init as a Averaging 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:

                radius   >= 0

Postconditions:

                1. left()  == -radius
                2. right() ==  radius
                3. borderTreatment() == BORDER_TREATMENT_CLIP
                4. norm() == norm

void initBinomial | ( | int | radius | ) | `[inline]`

| Init as a Binomial filter with norm 1.

void initBinomial | ( | int | radius,
|  | value_type | norm
| ) |

Init as a Binomial filter. 'norm' denotes the sum of all bins of the kernel.

Precondition:

                radius   >= 0

Postconditions:

                1. left()  == -radius
                2. right() ==  radius
                3. borderTreatment() == BORDER_TREATMENT_REFLECT
                4. norm() == norm

void initDiscreteGaussian | ( | double | std_dev | ) | `[inline]`

| Init as a LOineberg's discrete analog of the Gaussian function with norm 1.

void initDiscreteGaussian | ( | double | std_dev,
|  | value_type | norm
| ) |

Init as Lindeberg's discrete analog of the Gaussian function. The radius of the kernel is always 3*std_dev. 'norm' denotes the sum of all bins of the kernel.

Precondition:

                std_dev >= 0.0

Postconditions:

                1. left()  == -(int)(3.0*std_dev + 0.5)
                2. right() ==  (int)(3.0*std_dev + 0.5)
                3. borderTreatment() == BORDER_TREATMENT_REFLECT
                4. norm() == norm

Kernel1D& initExplicitly | ( | int | left,
|  | int | right
| ) | `[inline]`

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:

                // define horizontal Roberts filter
                vigra::Kernel1D<float> roberts_gradient_x;

                roberts_gradient_x.initExplicitly(0, 1) = 1.0, -1.0;

The norm is set to the sum of the initialzer 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:

                vigra::Kernel1D<float> average5x1;

                average5x1.initExplicitly(-2, 2) = 1.0/5.0;

Here, the norm is set to value*size().

Preconditions:

                1. left <= 0
                2. right >= 0
                3. the number of values in the initializer list
                   is 1 or equals the size of the kernel.

Examples:
  pyramid.cxx.

void initGaussian | ( | double | std_dev | ) | `[inline]`

| Init as a Gaussian function with norm 1.

void initGaussian | ( | double | std_dev,
|  | value_type | norm
| ) |

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.

Precondition:

                std_dev >= 0.0

Postconditions:

                1. left()  == -(int)(3.0*std_dev + 0.5)
                2. right() ==  (int)(3.0*std_dev + 0.5)
                3. borderTreatment() == BORDER_TREATMENT_CLIP
                4. norm() == norm

Examples:
  smooth.cxx.

void initGaussianDerivative | ( | double | std_dev,
|  | int | order
| ) | `[inline]`

| Init as a Gaussian derivative with norm 1.

void initGaussianDerivative | ( | double | std_dev,
|  | int | order,
|  | value_type | norm
| ) |

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.

Preconditions:

                1. std_dev >= 0.0
                2. order   >= 1

Postconditions:

                1. left()  == -(int)(3.0*std_dev + 0.5*order + 0.5)
                2. right() ==  (int)(3.0*std_dev + 0.5*order + 0.5)
                3. borderTreatment() == BORDER_TREATMENT_REPEAT
                4. norm() == norm

void initSymmetricGradient | ( |  | ) | `[inline]`

| Init as a symmetric gradient 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]`

Postconditions:

                1. left()  == -1
                2. right() ==  1
                3. borderTreatment() == BORDER_TREATMENT_REPEAT
                4. norm() == norm

int left | ( |  | ) | const`[inline]`

| left border of kernel (inclusive), always <= 0

value_type norm | ( |  | ) | const`[inline]`

| norm of kernel

void normalize | ( |  | ) | `[inline]`

| normalize kernel to norm 1.

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.

InitProxy operator= | ( | value_type const & | v | ) | `[inline]`

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:

                vigra::Kernel1D<float> roberts_gradient_x;

                roberts_gradient_x.initExplicitly(0, 1) = 1.0, -1.0;

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.

Kernel1D& operator= | ( | Kernel1D< ARITHTYPE > const & | k | ) | `[inline]`

| Copy assignment.

reference operator[] | ( | int | location | ) | `[inline]`

Access kernel value at specified location.

Preconditions:

                left() <= location <= right()

int right | ( |  | ) | const`[inline]`

| right border of kernel (inclusive), always >= 0

void setBorderTreatment | ( | BorderTreatmentMode | new_mode | ) | `[inline]`

| Set border treatment mode.

int size | ( |  | ) | const`[inline]`

| size of kernel (right() - left() + 1)

The documentation for this class was generated from the following file:

- vigra/separableconvolution.hxx

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.4.0 (21 Dec 2005)