latest version v1.9 - last update 10 Apr 2010 |
one-dimensional filter kernel More...
#include <ltiLinearKernels.h>
Public Member Functions | |
kernel1D () | |
kernel1D (const int &from, const int &to, const T &init=T()) | |
kernel1D (const vector< T > &other, const int &theOffset) | |
kernel1D (const bool &init, const int &from, const int &to) | |
kernel1D (const kernel1D &other) | |
virtual | ~kernel1D () |
const char * | getTypeName () const |
kernel1D & | copy (const kernel1D &other) |
virtual mathObject * | clone () const |
template<class U > | |
kernel1D & | castFrom (const kernel1D< U > &other) |
kernel1D< T > & | castFrom (const vector< T > &other, const int &firstElement=0) |
int | getOffset () const |
void | setOffset (const int &theOffset) |
const T & | getNorm () const |
void | setNorm (const T &n) |
void | denormalize () |
kernel1D< T > & | mirror (const kernel1D< T > &other) |
kernel1D< T > & | mirror () |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Protected Attributes | |
T | norm |
one-dimensional filter kernel
The template type of this class should coincide with the template class of the vector be convolved with. For example, if you want to convolve a kernel1D with a vector<double>, you will need a kernel1D<double> (
If you instantiate a kernel1D of a fixed point type, like kernel1D<int> or kernel1D<ubyte>, you also need to consider the "norm" of the kernel (see lti::kernel1D<T>::getNorm() and lti::kernel1D<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 kernel1D<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
lti::kernel1D< T >::kernel1D | ( | ) |
default constructor
lti::kernel1D< T >::kernel1D | ( | const int & | from, | |
const int & | to, | |||
const T & | init = T() | |||
) |
construct a filter kernel indexed from from to to and initialized with the value init
lti::kernel1D< T >::kernel1D | ( | const vector< T > & | other, | |
const int & | theOffset | |||
) |
lti::kernel1D< T >::kernel1D | ( | const bool & | init, | |
const int & | from, | |||
const int & | to | |||
) |
If init is true this constructor is equivalent to calling kernel1D(const int& from, const int& to), 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 kernel1Ds, the unnecessary constructor initialization is very time consuming.
If init is false, memory is allocated but no initialization takes place.
init | initialize matrix or not | |
from | first index | |
to | last index |
lti::kernel1D< T >::kernel1D | ( | const kernel1D< T > & | other | ) |
copy constructor
other | the one dimensional kernel to be copied |
virtual lti::kernel1D< T >::~kernel1D | ( | ) | [virtual] |
destructor
kernel1D<T>& lti::kernel1D< T >::castFrom | ( | const vector< T > & | other, | |
const int & | firstElement = 0 | |||
) |
copy the content of the other vector in this kernel and assign the index (firstElement) to the first element of the vector.
For example if other
is a 3 dimensional vector, then castFrom(other,-1)
is a 3-elements-kernel which indices lay inside [-1,1].
other | the vector with the data to be copied | |
firstElement | index for the first element of the vector |
kernel1D& lti::kernel1D< T >::castFrom | ( | const kernel1D< U > & | other | ) | [inline] |
copy from kernel of different type
other | a one dimensional kernel of another type |
Reimplemented from lti::array< T >.
Referenced by lti::kernel1D< float >::castFrom().
virtual mathObject* lti::kernel1D< T >::clone | ( | ) | const [inline, virtual] |
kernel1D& lti::kernel1D< T >::copy | ( | const kernel1D< T > & | other | ) |
copy member
other | the one dimensional kernel to be copied |
Reimplemented from lti::array< T >.
void lti::kernel1D< T >::denormalize | ( | ) |
denormalize divide all elements by norm and set the norm to 1!
const T& lti::kernel1D< T >::getNorm | ( | ) | const [inline] |
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.
Referenced by lti::kernel1D< float >::castFrom().
int lti::kernel1D< T >::getOffset | ( | ) | const |
get offset position of element 0
const char* lti::kernel1D< T >::getTypeName | ( | void | ) | const [inline, virtual] |
returns name of this type ("kernel1D")
Reimplemented from lti::array< T >.
kernel1D<T>& lti::kernel1D< T >::mirror | ( | ) |
Mirror this kernel, i.e.
at(y,x) = at(-y,-x);
kernel1D<T>& lti::kernel1D< T >::mirror | ( | const kernel1D< T > & | other | ) |
Mirror the other kernel and leave the result here, i.e.
at(x) = other.at(-x);
other | the kernel to be copied and then mirrored |
virtual bool lti::kernel1D< T >::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the object from the given ioHandler
Reimplemented from lti::array< T >.
void lti::kernel1D< T >::setNorm | ( | const T & | n | ) | [inline] |
set normalization factor
void lti::kernel1D< T >::setOffset | ( | const int & | theOffset | ) |
set offset position of element 0
virtual bool lti::kernel1D< T >::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
write the object in the given ioHandler
Reimplemented from lti::array< T >.
T lti::kernel1D< T >::norm [protected] |
Normalisation factor.
This value will be ignored for floating point formats. For fixed point formats, this value corresponds to 1.0
Referenced by lti::kernel1D< float >::castFrom(), lti::kernel1D< float >::getNorm(), and lti::kernel1D< float >::setNorm().