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

lti::maskFunctor< T > Class Template Reference

The mask functor is a colection of boolean operations used in the processing of mask images or matrices. More...

#include <ltiMaskFunctors.h>

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

List of all members.

Public Member Functions

 maskFunctor ()
 maskFunctor (const maskFunctor< T > &other)
virtual ~maskFunctor ()
const char * getTypeName () const
functorclone () const
void copy (const maskFunctor< T > &other)
matrix< T > & multiply (const matrix< T > &m1, matrix< T > &m2)
matrix< T > & multiply (const matrix< T > &m1, const matrix< T > &m2, matrix< T > &result)
matrix< T > & algebraicSum (const matrix< T > &m1, matrix< T > &m2)
matrix< T > & algebraicSum (const matrix< T > &m1, const matrix< T > &m2, matrix< T > &result)
matrix< T > & maskOr (const matrix< T > &m1, matrix< T > &m2)
matrix< T > & maskOr (const matrix< T > &m1, const matrix< T > &m2, matrix< T > &result)
matrix< T > & maskAnd (const matrix< T > &m1, matrix< T > &m2)
matrix< T > & maskAnd (const matrix< T > &m1, const matrix< T > &m2, matrix< T > &result)
matrix< T > & maskNot (matrix< T > &m)
matrix< T > & maskNot (const matrix< T > &m1, matrix< T > &result)
matrix< T > & invert (matrix< T > &m)
matrix< T > & invert (const matrix< T > &m1, matrix< T > &result)
bool apply (const matrix< T > &m1, matrix< T > &result, T(*function)(const T &, const T &)) const
bool apply (matrix< T > &srcdest, T(*function)(const T &, const T &)) const
bool apply (const matrix< T > &m1, const matrix< T > &m2, matrix< T > &result, T(*function)(const T &, const T &, const T &)) const
bool apply (const matrix< T > &m1, matrix< T > &srcdest, T(*function)(const T &, const T &, const T &)) const
virtual bool apply (const matrix< T > &m1, const matrix< T > &m2, matrix< T > &result) const
virtual bool apply (const matrix< T > &m1, matrix< T > &result) const

Protected Types

enum  eFunctionType { Black, NoEffect, White, Unknown }

Protected Member Functions

eFunctionType check (T(*function)(const T &, const T &, const T &), const int &par) const

Static Protected Member Functions

static T multiplyNorm (const T &a, const T &b, const T &norm)
static T multiplyNoNorm (const T &a, const T &b, const T &norm)
static T algebraicSumNorm (const T &a, const T &b, const T &norm)
static T algebraicSumNoNorm (const T &a, const T &b, const T &norm)
static T orNorm (const T &a, const T &b, const T &norm)
static T andNorm (const T &a, const T &b, const T &norm)
static T notMaskNorm (const T &a, const T &norm)
static T invertNorm (const T &a, const T &norm)

Detailed Description

template<class T>
class lti::maskFunctor< T >

The mask functor is a colection of boolean operations used in the processing of mask images or matrices.

All members are used in derived classes, which provide the LTI-Lib standard interface. The template parameter is the type of the matrices to be operated and NOT the whole matrix type. For example:

 lti::maskFunctor<channel8::value_type> masker;
 channel8 a,b,result;
 ...
 masker.multiply(a,b,result);
See also:
lti::maskMultiply, lti::maskAlgebraicSum, lti::maskOr, lti::maskAnd, lti::maskNot, lti::maskInvert

Member Enumeration Documentation

template<class T>
enum lti::maskFunctor::eFunctionType [protected]

a static member can be one of following things

Enumerator:
Black 

if a parameter is zero, the result is zero

NoEffect 

if a parameter is zero, the result will be the other value

White 

if the result is zero, the result will be the norm

Unknown 

unknown masking effect!


Constructor & Destructor Documentation

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

constructor

Referenced by lti::maskFunctor< T >::clone().

template<class T>
lti::maskFunctor< T >::maskFunctor ( const maskFunctor< T > &  other  )  [inline]

copy constructor

References lti::maskFunctor< T >::copy().

template<class T>
virtual lti::maskFunctor< T >::~maskFunctor (  )  [virtual]

destructor


Member Function Documentation

template<class T>
matrix<T>& lti::maskFunctor< T >::algebraicSum ( const matrix< T > &  m1,
const matrix< T > &  m2,
matrix< T > &  result 
)

calculates the algebraic sum for each element of the matrixes.

The algebraic sum of a and b is defined as follows:

 s = 1 - (1-a)(1-b). 

This is used in the implementation of OR. The size of result is as big as the biggest matrix.

Parameters:
m1 first matrix
m2 second matrix
result result container
Returns:
a reference to result
template<class T>
matrix<T>& lti::maskFunctor< T >::algebraicSum ( const matrix< T > &  m1,
matrix< T > &  m2 
)

calculates the algebraic sum for each element of the normalized matrixes.

The algebraic sum of a and b is defined as follows:

 s = 1 - (1-a)(1-b).  

This is some sort of OR operator. The size of m1 will not be modified (i.e. only the common submatrix will be considered)

Parameters:
m1 first matrix
m2 second matrix and result container
Returns:
a reference to m2

Referenced by lti::maskAlgebraicSum< T >::apply().

template<class T>
static T lti::maskFunctor< T >::algebraicSumNoNorm ( const T &  a,
const T &  b,
const T &  norm 
) [inline, static, protected]

calculates algebraic sum = norm - (norm-a)*(norm-b)/norm

Parameters:
a first parameter
b second parameter
norm norm factor used
Returns:
norm - (norm-a)*(norm-b)/norm
template<class T>
static T lti::maskFunctor< T >::algebraicSumNorm ( const T &  a,
const T &  b,
const T &  norm 
) [inline, static, protected]

calculates the algebraic sum = norm - (norm-a)*(norm-b)/norm

Parameters:
a first parameter
b second parameter
norm norm factor used
Returns:
norm - (norm-a)*(norm-b)/norm
template<class T>
static T lti::maskFunctor< T >::andNorm ( const T &  a,
const T &  b,
const T &  norm 
) [inline, static, protected]

calculates (a and b)

Parameters:
a first parameter
b second parameter
norm norm factor used
Returns:
a and b
template<class T>
virtual bool lti::maskFunctor< T >::apply ( const matrix< T > &  m1,
matrix< T > &  result 
) const [inline, virtual]

this "dummy" apply member is just an interface for the subclasses which will follow the standard LTI-Lib approach.

This doesn't do anything at all...

Parameters:
m1 the first matrix to operate with
result the matrix where the result will be left
Returns:
true if successful, false otherwise.
template<class T>
virtual bool lti::maskFunctor< T >::apply ( const matrix< T > &  m1,
const matrix< T > &  m2,
matrix< T > &  result 
) const [inline, virtual]

this "dummy" apply member is just an interface for the subclasses which will follow the standard LTI-Lib approach.

This doesn't do anything at all...

Parameters:
m1 the first matrix to operate with
m2 the second matrix to operate with
result the matrix where the result will be left
Returns:
true if successful, false otherwise.
template<class T>
bool lti::maskFunctor< T >::apply ( const matrix< T > &  m1,
matrix< T > &  srcdest,
T(*)(const T &, const T &, const T &)  function 
) const

apply the given function at each element of m1 and srcdest and leave the result in the srcdest matrix.

Parameters:
m1 the first matrix
srcdest the second matrix and also the resulting matrix. Its size won't be changed. For those parts covered only by one of the matrices, the assumed value for the other one will be zero.
function the function to be applied. The first parameter will be the element value of the first matrix, the second parameter the element value of the second matrix and the third parameter will be usually a normalization factor.
Returns:
true if successful, false otherwise.
template<class T>
bool lti::maskFunctor< T >::apply ( const matrix< T > &  m1,
const matrix< T > &  m2,
matrix< T > &  result,
T(*)(const T &, const T &, const T &)  function 
) const

apply the given function at each element of m1 and m2 and leave the result in the result matrix.

Parameters:
m1 the first matrix
m2 the second matrix
result the resulting matrix. The size of this matrix will be the smallest matrix which can contain both matrices m1 and m2. For those parts covered only by one of the matrices, the assumed value for the other one will be zero.
function the function to be applied. The first parameter will be the element value of the first matrix, the second parameter the element value of the second matrix and the third parameter will be usually a normalization factor.
Returns:
true if successful, false otherwise.
template<class T>
bool lti::maskFunctor< T >::apply ( matrix< T > &  srcdest,
T(*)(const T &, const T &)  function 
) const

apply the given function at each pixel of srcdest and leave the result there too.

Parameters:
srcdest the source and destination matrix
function the function to be applied. The first parameter will be the element value of the first matrix, the second parameter will be usually a normalization factor.
Returns:
true if successful, false otherwise.
template<class T>
bool lti::maskFunctor< T >::apply ( const matrix< T > &  m1,
matrix< T > &  result,
T(*)(const T &, const T &)  function 
) const

apply the given function at each pixel of m1 and leave the result in the result matrix.

Parameters:
m1 the first matrix
result the resulting matrix. The size of this matrix will be the size of m1
function the function to be applied. The first parameter will be the element value of the first matrix, the second parameter will be usually a normalization factor.
Returns:
true if successful, false otherwise.
template<class T>
eFunctionType lti::maskFunctor< T >::check ( T(*)(const T &, const T &, const T &)  function,
const int &  par 
) const [protected]

check a function.

if par==0 the first parameter will be set to zero otherwise the second parameters will be set to zero.

Parameters:
function the function to be checked
par flag used.
Returns:
the function type
template<class T>
functor* lti::maskFunctor< T >::clone (  )  const [inline, virtual]

clones this object

Implements lti::functor.

References lti::maskFunctor< T >::maskFunctor().

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

copy

Reimplemented from lti::functor.

Referenced by lti::maskFunctor< T >::maskFunctor().

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

returns the name of this type

Reimplemented from lti::functor.

template<class T>
matrix<T>& lti::maskFunctor< T >::invert ( const matrix< T > &  m1,
matrix< T > &  result 
)

inverts the values in the matrix m, where "inversion" means the suggestedNorm() minus the original matrix entry value.

Parameters:
m1 matrix to be inverted.
result the result is left here.
Returns:
a reference to the matrix result.
template<class T>
matrix<T>& lti::maskFunctor< T >::invert ( matrix< T > &  m  ) 

inverts the values in the matrix m, where "inversion" means the suggestedNorm() minus the original matrix entry value.

Parameters:
m matrix to be inverted. The result is left here too.
Returns:
a reference to the matrix m

Referenced by lti::maskInvert< T >::apply().

template<class T>
static T lti::maskFunctor< T >::invertNorm ( const T &  a,
const T &  norm 
) [inline, static, protected]

calculates norm-a;

Parameters:
a first parameter
norm norm factor used
Returns:
norm-a
template<class T>
matrix<T>& lti::maskFunctor< T >::maskAnd ( const matrix< T > &  m1,
const matrix< T > &  m2,
matrix< T > &  result 
)

the result pixel will contain the norm value (see suggestedNorm()) if both mask's pixels are not zero, otherwise the value is zero.

Parameters:
m1 first matrix
m2 second matrix
result result container
Returns:
a reference to result
template<class T>
matrix<T>& lti::maskFunctor< T >::maskAnd ( const matrix< T > &  m1,
matrix< T > &  m2 
)

the m2 pixel will contain the norm value (see suggestedNorm()) if both mask's pixels are not zero, otherwise the value is zero.

Parameters:
m1 first matrix
m2 second matrix and result container
Returns:
a reference to m2

Referenced by lti::maskAnd< T >::apply().

template<class T>
matrix<T>& lti::maskFunctor< T >::maskNot ( const matrix< T > &  m1,
matrix< T > &  result 
)

the result of the mask will be zero if the original value is not zero and viceversa.

Parameters:
m1 first matrix
result result container
Returns:
a reference to result
template<class T>
matrix<T>& lti::maskFunctor< T >::maskNot ( matrix< T > &  m  ) 

the value of the mask will be zero if the original value is not zero and viceversa.

Parameters:
m matrix to be inverted. The result will be left here too.
Returns:
a reference to m

Referenced by lti::maskNot< T >::apply().

template<class T>
matrix<T>& lti::maskFunctor< T >::maskOr ( const matrix< T > &  m1,
const matrix< T > &  m2,
matrix< T > &  result 
)

the result pixel will contain the norm value (see suggestedNorm()) if any of both mask's pixels is not null

Parameters:
m1 first matrix
m2 second matrix
result result container
Returns:
a reference to result
template<class T>
matrix<T>& lti::maskFunctor< T >::maskOr ( const matrix< T > &  m1,
matrix< T > &  m2 
)

the m2 pixel will contain the norm value (see suggestedNorm()) if any of both mask's pixels is not null

Parameters:
m1 first matrix
m2 second matrix and result container
Returns:
a reference to m2

Referenced by lti::maskOr< T >::apply().

template<class T>
matrix<T>& lti::maskFunctor< T >::multiply ( const matrix< T > &  m1,
const matrix< T > &  m2,
matrix< T > &  result 
)

multiplies the normalized first mask with the second and leaves the result on the third mask.

The size of 'result' is as big as the biggest matrix.

Parameters:
m1 first matrix
m2 second matrix
result result container
Returns:
a reference to result
template<class T>
matrix<T>& lti::maskFunctor< T >::multiply ( const matrix< T > &  m1,
matrix< T > &  m2 
)

multiplies the normalized first mask with the second and leaves the result on the second mask.

The size of m2 will not be modified (i.e. only the common submatrix will be considered!!!)

Parameters:
m1 first matrix
m2 second matrix and result container
Returns:
a reference to m2

Referenced by lti::maskMultiply< T >::apply().

template<class T>
static T lti::maskFunctor< T >::multiplyNoNorm ( const T &  a,
const T &  b,
const T &  norm 
) [inline, static, protected]

calculates a*b;

Parameters:
a first parameter
b second parameter
norm norm factor used
Returns:
a*b
template<class T>
static T lti::maskFunctor< T >::multiplyNorm ( const T &  a,
const T &  b,
const T &  norm 
) [inline, static, protected]

calculates a*b/norm;

Parameters:
a first parameter
b second parameter
norm norm factor used
Returns:
a*b/norm
template<class T>
static T lti::maskFunctor< T >::notMaskNorm ( const T &  a,
const T &  norm 
) [inline, static, protected]

calculates (not a)

Parameters:
a first parameter
norm norm factor used
Returns:
not a
template<class T>
static T lti::maskFunctor< T >::orNorm ( const T &  a,
const T &  b,
const T &  norm 
) [inline, static, protected]

calculates (a or b)

Parameters:
a first parameter
b second parameter
norm norm factor used
Returns:
a or b

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

Generated on Sat Apr 10 15:28:30 2010 for LTI-Lib by Doxygen 1.6.1