latest version v1.9 - last update 10 Apr 2010 |
The mask functor is a colection of boolean operations used in the processing of mask images or matrices. More...
#include <ltiMaskFunctors.h>
Public Member Functions | |
maskFunctor () | |
maskFunctor (const maskFunctor< T > &other) | |
virtual | ~maskFunctor () |
const char * | getTypeName () const |
functor * | clone () 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) |
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);
enum lti::maskFunctor::eFunctionType [protected] |
lti::maskFunctor< T >::maskFunctor | ( | ) |
constructor
Referenced by lti::maskFunctor< T >::clone().
lti::maskFunctor< T >::maskFunctor | ( | const maskFunctor< T > & | other | ) | [inline] |
copy constructor
References lti::maskFunctor< T >::copy().
virtual lti::maskFunctor< T >::~maskFunctor | ( | ) | [virtual] |
destructor
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.
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)
Referenced by lti::maskAlgebraicSum< T >::apply().
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
a | first parameter | |
b | second parameter | |
norm | norm factor used |
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
a | first parameter | |
b | second parameter | |
norm | norm factor used |
static T lti::maskFunctor< T >::andNorm | ( | const T & | a, | |
const T & | b, | |||
const T & | norm | |||
) | [inline, static, protected] |
calculates (a and b)
a | first parameter | |
b | second parameter | |
norm | norm factor used |
virtual bool lti::maskFunctor< T >::apply | ( | const matrix< T > & | m1, | |
matrix< T > & | result | |||
) | const [inline, virtual] |
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...
m1 | the first matrix to operate with | |
m2 | the second matrix to operate with | |
result | the matrix where the result will be left |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
function | the function to be checked | |
par | flag used. |
functor* lti::maskFunctor< T >::clone | ( | ) | const [inline, virtual] |
void lti::maskFunctor< T >::copy | ( | const maskFunctor< T > & | other | ) |
const char* lti::maskFunctor< T >::getTypeName | ( | void | ) | const [inline, virtual] |
returns the name of this type
Reimplemented from lti::functor.
matrix<T>& lti::maskFunctor< T >::invert | ( | const matrix< T > & | m1, | |
matrix< T > & | result | |||
) |
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.
m | matrix to be inverted. The result is left here too. |
Referenced by lti::maskInvert< T >::apply().
static T lti::maskFunctor< T >::invertNorm | ( | const T & | a, | |
const T & | norm | |||
) | [inline, static, protected] |
calculates norm-a;
a | first parameter | |
norm | norm factor used |
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.
Referenced by lti::maskAnd< T >::apply().
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.
m1 | first matrix | |
result | result container |
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.
m | matrix to be inverted. The result will be left here too. |
Referenced by lti::maskNot< T >::apply().
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
Referenced by lti::maskOr< T >::apply().
matrix<T>& lti::maskFunctor< T >::multiply | ( | const matrix< T > & | m1, | |
const matrix< T > & | m2, | |||
matrix< T > & | result | |||
) |
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!!!)
Referenced by lti::maskMultiply< T >::apply().
static T lti::maskFunctor< T >::multiplyNoNorm | ( | const T & | a, | |
const T & | b, | |||
const T & | norm | |||
) | [inline, static, protected] |
calculates a*b;
a | first parameter | |
b | second parameter | |
norm | norm factor used |
static T lti::maskFunctor< T >::multiplyNorm | ( | const T & | a, | |
const T & | b, | |||
const T & | norm | |||
) | [inline, static, protected] |
calculates a*b/norm;
a | first parameter | |
b | second parameter | |
norm | norm factor used |
static T lti::maskFunctor< T >::notMaskNorm | ( | const T & | a, | |
const T & | norm | |||
) | [inline, static, protected] |
calculates (not a)
a | first parameter | |
norm | norm factor used |
static T lti::maskFunctor< T >::orNorm | ( | const T & | a, | |
const T & | b, | |||
const T & | norm | |||
) | [inline, static, protected] |
calculates (a or b)
a | first parameter | |
b | second parameter | |
norm | norm factor used |