|
latest version v1.9 - last update 24 Nov 2005 |
|
#include <ltiLinearKernels.h>
Inheritance diagram for lti::kernel2D< T >:


Public Member Functions | |
| kernel2D () | |
| kernel2D (const kernel2D &other) | |
| kernel2D (const int &rows, const int &columns, const T &iniValue=T()) | |
| kernel2D (const int &fromRow, const int &fromCol, const int &toRow, const int &toCol, const T &iniValue=T()) | |
| kernel2D (const bool &init, const int &rows, const int &columns) | |
| kernel2D (const bool &init, const int &fromRow, const int &fromCol, const int &toRow, const int &toCol) | |
| virtual | ~kernel2D () |
| kernel2D< T > & | copy (const kernel2D< T > &other) |
| const char * | getTypeName () const |
| virtual mathObject * | clone () const |
| template<class U> | |
| kernel2D< T > & | castFrom (const kernel2D< U > &other) |
| kernel2D< T > & | castFrom (const matrix< T > &other, const int &firstRow, const int &firstColumn) |
| kernel2D< T > & | castFrom (const matrix< T > &other, const point &firstElement=point(0, 0)) |
| kernel2D< T > & | castFrom (const sepKernel< T > &other) |
| void | resize (const int &fromRow, const int &fromCol, const int &toRow, const int &toCol, const T &iniValue=T(), const bool ©Data=true, const bool &initNew=true) |
| void | fill (const matrix< T > &mat, const int &fromRow=MinInt24, const int &fromCol=MinInt24, const int &toRow=MaxInt24, const int &toCol=MaxInt24, const int &startAtRow=0, const int &startAtCol=0) |
| void | fill (const T *data, const int &fromRow=MinInt24, const int &fromCol=MinInt24, const int &toRow=MaxInt24, const int &toCol=MaxInt24) |
| const T & | getNorm () const |
| void | setNorm (const T &n) |
| const point & | getOffset () const |
| void | setOffset (const point &p) |
| int | firstRow () const |
| int | lastRow () const |
| int | firstColumn () const |
| int | lastColumn () const |
| T & | at (const point &p) |
| const T & | at (const point &p) const |
| T & | at (const int &y, const int &x) |
| const T & | at (const int &y, const int &x) const |
| kernel2D< T > & | outerProduct (const kernel1D< T > &colKernel, const kernel1D< T > &rowKernel) |
| void | denormalize () |
| kernel2D< T > & | mirror (const kernel2D< T > &other) |
| kernel2D< T > & | mirror () |
| virtual bool | write (ioHandler &handler, const bool complete=true) const |
| virtual bool | read (ioHandler &handler, const bool complete=true) |
Protected Attributes | |
| point | offset |
| T | norm |
The template type of this class should coincide with the template class of the matrix or channel to be convolved with. For example, if you want to convolve a kernel2D with a channel8, you will need a kernel2D<channel8::value_type> or kernel2D<ubyte>. The offset of the kernel is at int(columns()/2),int(rows()/2). This means that for kernels of odd width and height, the origin (0,0) is exactly in the center, while for kernels with even width and/or height, it is shifted towards the upper left corner.
If you instantiate a kernel2D of a fixed point type, like kernel2D<int> or kernel2D<ubyte>, you also need to consider the "norm" of the kernel (see lti::kernel2D<T>::getNorm() and lti::kernel2D<T>::setNorm(const T&)). This "norm" allows the representation of numbers less than 1.0. You can see this norm as the value to be consider as 1.0, when operating with the kernel. For example, if you have a kernel2D<ubyte> with the values [64,128,64] and norm=255, the the interpreted values during convolution will be [0.25,0.5,0.25]. With floating-point types, the norm will be always assumed to be 1.0. For other types the default norms are the following:
For int: 65536 For ubyte: 255 Otherwise: 1.0
You can generate 2D kernels from separable ones using the castFrom() method. For example:
lti::gaussKernel2D<float> gauss(5); // a sepKernel 5x5 lti::kernel2D<float> kern; // a 2D kernel; kern.castFrom(gauss);
You can also use the outerProduct member to construct a 2D kernel from two 1D ones:
lti::gaussKernel1D<float> colKern(3); // a 1D kernel lti::gaussKernel1D<float> rowKern(5); // another 1D kernel lti::kernel2D<float> kern; // a 2D kernel; kern.outerProd(colKern,rowKern); // outer product of both kernels
|
|||||||||
|
default constructor
|
|
||||||||||
|
copy constructor
|
|
||||||||||||||||||||
|
Create a new kernel of indicated size and initial value. The offset is kept at zero.
|
|
||||||||||||||||||||||||||||
|
Create a new kernel with indicated indices.
lti::kernel2D<channel::value_type> aKernel(-1,-2,1,2,0); aKernel.at(-1,-2)=0.2; aKernel.at(-1,-1)=0.2; aKernel.at(0,0)=0.2; aKernel.at(1,1)=0.2; aKernel.at(1,2)=0.2; |
|
||||||||||||||||||||
|
If init is true this constructor is equivalent to calling kernel2D(const int& rows, const int& columns), and thus initializing all elements with T(). However, in some cases the elements need not be initialized during construction, since complex initializion is required. Especially for large kernel2Ds, the unnecessary constructor initialization is very time consuming. If init is false, memory is allocated but no initialization takes place.
|
|
||||||||||||||||||||||||||||
|
If init is true this constructor is equivalent to calling kernel2D(const int& fromRow,const int& fromCol, const int& toRow,const int& toCol), and thus initializing all elements with T(). However, in some cases the elements need not be initialized during construction, since complex initializion is required. Especially for large kernel2Ds, the unnecessary constructor initialization is very time consuming. If init is false, memory is allocated but no initialization takes place.
|
|
|||||||||
|
destructor
|
|
||||||||||||||||
|
access operator with offset
|
|
||||||||||||||||
|
access operator with offset
|
|
||||||||||
|
access operator with offset
Reimplemented from lti::genericMatrix< T >. |
|
||||||||||
|
access operator with offset
Reimplemented from lti::genericMatrix< T >. |
|
||||||||||
|
copy the contents of the other separable kernel in this two-dimensional kernel
|
|
||||||||||||||||
|
copy the content of the other matrix in this kernel and assign the index (firstRow,firstColumn) to the first element of the matrix.
For example if
|
|
||||||||||||||||||||
|
copy the content of the other matrix in this kernel and assign the index (firstRow,firstColumn) to the first element of the matrix.
For example if
|
|
||||||||||||||
|
copy from kernel of different type
|
|
|||||||||
|
clone member
Reimplemented from lti::matrix< T >. |
|
||||||||||
|
copy member
|
|
|||||||||
|
denormalize divide all elements by norm and set the norm to 1!
|
|
||||||||||||||||||||||||||||
|
fills this kernel between the "from's" and "to's" with the contents of the matrix
|
|
||||||||||||||||||||||||||||||||||||
|
fills this kernel between the "from's" and "to's" with the contents of the matrix
|
|
|||||||||
|
first column index
|
|
|||||||||
|
first row index
|
|
|||||||||
|
get normalization factor The normalization factor is used by the fixed point types as a representation of the value 1. For example, the norm for a kernel1D<ubyte> can be 255, if the filter kernel don't need values greater than 1.0. |
|
|||||||||
|
returns offset, i.e. center of the filter-kernel
|
|
||||||||||
|
returns name of this type ("kernel2D")
Reimplemented from lti::matrix< T >. |
|
|||||||||
|
last column index
Reimplemented from lti::genericMatrix< T >. |
|
|||||||||
|
last row index
Reimplemented from lti::genericMatrix< T >. |
|
|||||||||
|
Mirror this kernel, i.e. at(y,x) = at(-y,-x);
|
|
||||||||||
|
Mirror the other kernel and leave the result here, i.e. at(y,x) = other.at(-y,-x);
|
|
||||||||||||||||
|
outer product of two kernel1D. The first kernel is a column kernel and the second kernel is a row kernel.
The final kernel will contain colKernel.size() rows and rowKernel.size() columns. Each row will be equal to the rowKernel multiplied by the respective colKernel element. |
|
||||||||||||||||
|
read the object from the given ioHandler
Reimplemented from lti::genericMatrix< T >. |
|
||||||||||||||||||||||||||||||||||||
|
resize kernel with indicated indexes
|
|
||||||||||
|
set normalization factor
|
|
||||||||||
|
set kernel offset, i.e. center of the filter-kernel
|
|
||||||||||||||||
|
write the object in the given ioHandler
Reimplemented from lti::genericMatrix< T >. |
|
|||||
|
Normalisation factor. This value will be ignored for floating point formats. For fixed point formats, this value corresponds to 1.0 |
|
|||||
|
absolute coordinates of the kernel point (0,0)
|