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

lti::sepKernel< T > Class Template Reference

Separable Kernel. More...

#include <ltiLinearKernels.h>

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

List of all members.

Public Member Functions

 sepKernel ()
 sepKernel (const sepKernel &other)
 sepKernel (const int &from, const int &to, const T &iniValue=T())
 sepKernel (const kernel1D< T > &subkernel)
virtual ~sepKernel ()
sepKernelcopy (const sepKernel &other)
const char * getTypeName () const
virtual mathObjectclone () const
template<class U >
sepKernelcastFrom (const sepKernel< U > &other)
bool separate (const kernel2D< T > &k, const double &maxDev=0.01)
int getNumberOfPairs () const
void setNumberOfPairs (const int &numPairs)
kernel1D< T > & getRowFilter (const int &i)
kernel1D< T > & getColFilter (const int &i)
const kernel1D< T > & getRowFilter (const int &i) const
const kernel1D< T > & getColFilter (const int &i) const
void denormalize ()
sepKernel< T > & multiply (const T &value)
void setNorm (const T &newNorm)
sumOfElements () const
sepKernel< T > & mirror (const sepKernel< T > &other)
sepKernel< T > & mirror ()
virtual bool write (ioHandler &handler, const bool complete=true) const
virtual bool read (ioHandler &handler, const bool complete=true)
Apply Methods



sepKernel< T > & apply (T(*function)(T))
sepKernel< T > & apply (T(*function)(const T &))
sepKernel< T > & apply (const sepKernel< T > &other, T(*function)(T))
sepKernel< T > & apply (const sepKernel< T > &other, T(*function)(const T &))

Protected Attributes

std::vector< kernel1D< T > > rowKernels
std::vector< kernel1D< T > > colKernels

Detailed Description

template<class T>
class lti::sepKernel< T >

Separable Kernel.

A separable kernel is a vector of one dimensional kernels. If a two dimensional kernel can be separated, the convolution can be applied in a very efficient way.

A filter kernel K is called separable "in one pair", if the matrix representation of K can be produced as an outer product of two one-dimensional kernels Kx and Ky.

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 sepKernel with a lti::channel, you will need a sepKernel<channel::value_type> or sepKernel<float>.

If you instantiate a sepKernel of a fixed point type, like sepKernel<int> or sepKernel<ubyte>, you also need to consider the "norm" of the kernel (see lti::sepKernel<T>::getNorm() and lti::sepKernel<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 sepKernel<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: (see lti::typeInfo)

See also:
convolution

Constructor & Destructor Documentation

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

default constructor

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

copy constructor

Parameters:
other the kernel to be copied.
template<class T>
lti::sepKernel< T >::sepKernel ( const int &  from,
const int &  to,
const T &  iniValue = T() 
)

construct a separable kernel with one filter pair, all elements of the subfilters initialized with the given value.

Parameters:
from first index of the one dimensional filter kernel
to last index of the one dimensional filter kernel
iniValue initial value for the kernel elements
template<class T>
lti::sepKernel< T >::sepKernel ( const kernel1D< T > &  subkernel  ) 

construct a symmetrical separable kernel

The resulting separable kernel will have just one filter pair, where the row and column filters are identical.

Parameters:
subkernel the one-dimensional kernel to be used as row and column filter.
template<class T>
virtual lti::sepKernel< T >::~sepKernel (  )  [virtual]

destructor


Member Function Documentation

template<class T>
sepKernel<T>& lti::sepKernel< T >::apply ( const sepKernel< T > &  other,
T(*)(const T &)  function 
)

applies a C-function to each element the other kernel and leaves the result here.

Parameters:
other the kernel with the source data
function a pointer to a C-function
Returns:
a reference to the actual kernel
template<class T>
sepKernel<T>& lti::sepKernel< T >::apply ( const sepKernel< T > &  other,
T(*)(T)  function 
)

applies a C-function to each element of the other kernel and leaves the result here.

Parameters:
other the source kernel
function a pointer to a C-function
Returns:
a reference to the actual kernel
template<class T>
sepKernel<T>& lti::sepKernel< T >::apply ( T(*)(const T &)  function  ) 

applies a C-function to each element of the kernel.

Parameters:
function a pointer to a C-function
Returns:
a reference to the actual kernel
template<class T>
sepKernel<T>& lti::sepKernel< T >::apply ( T(*)(T)  function  ) 

applies a C-function to each element of the kernel.

In the following example, kernel kernel is initialized with 4.0. After applying sqrt(), all elements of kernel are 2.0.

 sepKernel<float> kern(-2,2,4.0);
 kern.apply(sqrt);
Parameters:
function a pointer to a C-function
Returns:
a reference to the actual kernel
template<class T>
template<class U >
sepKernel& lti::sepKernel< T >::castFrom ( const sepKernel< U > &  other  )  [inline]

copy from kernel of another type

Parameters:
other a separable kernel of another type
Returns:
a reference to this instance
template<class T>
virtual mathObject* lti::sepKernel< T >::clone (  )  const [inline, virtual]

clone member

Returns:
a pointer to a copy of this instance

Implements lti::mathObject.

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

copy member

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

Reimplemented from lti::ioObject.

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

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

template<class T>
const kernel1D<T>& lti::sepKernel< T >::getColFilter ( const int &  i  )  const [inline]

return an unmodifiable column kernel

Parameters:
i the index of the column filter. This value must be between 0 and getNumberOfPairs()
template<class T>
kernel1D<T>& lti::sepKernel< T >::getColFilter ( const int &  i  )  [inline]

return a column-kernel

Parameters:
i the index of the column filter. This value must be between 0 and getNumberOfPairs()

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

template<class T>
int lti::sepKernel< T >::getNumberOfPairs (  )  const

number of filter pairs

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

template<class T>
const kernel1D<T>& lti::sepKernel< T >::getRowFilter ( const int &  i  )  const [inline]

return an unmodifiable row kernel

Parameters:
i the index of the row filter. This value must be between 0 and getNumberOfPairs()
template<class T>
kernel1D<T>& lti::sepKernel< T >::getRowFilter ( const int &  i  )  [inline]

return a row-kernel

Parameters:
i the index of the row filter. This value must be between 0 and getNumberOfPairs()

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

template<class T>
const char* lti::sepKernel< T >::getTypeName ( void   )  const [inline, virtual]

returns name of this type ("sepKernel")

Reimplemented from lti::mathObject.

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

Mirror this kernel, i.e.

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

Returns:
a reference to this instance
template<class T>
sepKernel<T>& lti::sepKernel< T >::mirror ( const sepKernel< T > &  other  ) 

Mirror the other kernel and leave the result here, i.e.

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

Parameters:
other the kernel to be copied and then mirrored
Returns:
a reference to this instance
template<class T>
sepKernel<T>& lti::sepKernel< T >::multiply ( const T &  value  ) 

multiply each 1D kernel with a constant value

Parameters:
value the value to be multiplied with
Returns:
a reference to this object
template<class T>
virtual bool lti::sepKernel< T >::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

read the object from the given ioHandler

Reimplemented from lti::mathObject.

template<class T>
bool lti::sepKernel< T >::separate ( const kernel2D< T > &  k,
const double &  maxDev = 0.01 
)

separate a 2D kernel into 1D kernels

Try to separate the two dimensional kernel k. Stop the separation if the error between original and separated kernel is less than maxDev.

Parameters:
k the two dimensional filter to be separated
maxDev the maximal deviation per element to be achieved
Returns:
true if the separation succeeded or false otherwise.
template<class T>
void lti::sepKernel< T >::setNorm ( const T &  newNorm  ) 

set the norm of each individual 1D kernel to the given value

Parameters:
newNorm the value to be used as norm
Returns:
a reference to this object
template<class T>
void lti::sepKernel< T >::setNumberOfPairs ( const int &  numPairs  ) 

set the number of column/row 1D-filters

template<class T>
T lti::sepKernel< T >::sumOfElements (  )  const

returns the sum of the elements of the resulting 2D kernel

template<class T>
virtual bool lti::sepKernel< T >::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

write the object in the given ioHandler

Reimplemented from lti::mathObject.


Member Data Documentation

template<class T>
std::vector< kernel1D<T> > lti::sepKernel< T >::colKernels [protected]

list of one-dimensional column kernels

Referenced by lti::sepKernel< float >::castFrom(), and lti::sepKernel< float >::getColFilter().

template<class T>
std::vector< kernel1D<T> > lti::sepKernel< T >::rowKernels [protected]

list of one-dimensional row kernels

Referenced by lti::sepKernel< float >::castFrom(), and lti::sepKernel< float >::getRowFilter().


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