LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::kernel1D< T > Class Template Reference

one-dimensional filter kernel More...

#include <ltiLinearKernels.h>

Inheritance diagram for lti::kernel1D< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::kernel1D< T >:
Collaboration graph
[legend]

List of all members.

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
kernel1Dcopy (const kernel1D &other)
virtual mathObjectclone () const
template<class U >
kernel1DcastFrom (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

norm

Detailed Description

template<class T>
class lti::kernel1D< T >

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> (

See also:
lti::convolution).

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

See also:
lti::convolution

Constructor & Destructor Documentation

template<class T>
lti::kernel1D< T >::kernel1D (  ) 

default constructor

template<class T>
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

template<class T>
lti::kernel1D< T >::kernel1D ( const vector< T > &  other,
const int &  theOffset 
)

construct a kernel from a one dimensional vector

Parameters:
other the source vector
theOffset this is the index in the vector that corresponds to the index '0' in the filter kernel
template<class T>
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.

Parameters:
init initialize matrix or not
from first index
to last index
template<class T>
lti::kernel1D< T >::kernel1D ( const kernel1D< T > &  other  ) 

copy constructor

Parameters:
other the one dimensional kernel to be copied
template<class T>
virtual lti::kernel1D< T >::~kernel1D (  )  [virtual]

destructor


Member Function Documentation

template<class T>
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].

Parameters:
other the vector with the data to be copied
firstElement index for the first element of the vector
Returns:
a reference to this instance
template<class T>
template<class U >
kernel1D& lti::kernel1D< T >::castFrom ( const kernel1D< U > &  other  )  [inline]

copy from kernel of different type

Parameters:
other a one dimensional kernel of another type
Returns:
a reference to this instance

Reimplemented from lti::array< T >.

Referenced by lti::kernel1D< float >::castFrom().

template<class T>
virtual mathObject* lti::kernel1D< T >::clone (  )  const [inline, virtual]

clone member

Returns:
a pointer to a copy of this object

Reimplemented from lti::vector< T >.

template<class T>
kernel1D& lti::kernel1D< T >::copy ( const kernel1D< T > &  other  ) 

copy member

Parameters:
other the one dimensional kernel to be copied
Returns:
a reference to this instance

Reimplemented from lti::array< T >.

template<class T>
void lti::kernel1D< T >::denormalize (  ) 

denormalize divide all elements by norm and set the norm to 1!

template<class T>
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().

template<class T>
int lti::kernel1D< T >::getOffset (  )  const

get offset position of element 0

Returns:
the position of the element with index 0 in the memory array. This value is the same as -firstIdx()
template<class T>
const char* lti::kernel1D< T >::getTypeName ( void   )  const [inline, virtual]

returns name of this type ("kernel1D")

Reimplemented from lti::array< T >.

template<class T>
kernel1D<T>& lti::kernel1D< T >::mirror (  ) 

Mirror this kernel, i.e.

at(y,x) = at(-y,-x);

Returns:
a reference to this instance
template<class T>
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);

Parameters:
other the kernel to be copied and then mirrored
Returns:
a reference to this instance
template<class T>
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 >.

template<class T>
void lti::kernel1D< T >::setNorm ( const T &  n  )  [inline]

set normalization factor

See also:
getNorm()
template<class T>
void lti::kernel1D< T >::setOffset ( const int &  theOffset  ) 

set offset position of element 0

Returns:
the position of the element with index 0 in the memory array. This value is the same as -firstIdx()
template<class T>
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 >.


Member Data Documentation

template<class 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().


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

Generated on Sat Apr 10 15:27:29 2010 for LTI-Lib by Doxygen 1.6.1