Basic Image AlgorithmS Library 2.8.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends

BIAS::FilterMask Class Reference

A filter mask (or a kernel) used for convolution. More...

#include <Filter/FilterMask.hh>

Inheritance diagram for BIAS::FilterMask:
Collaboration diagram for BIAS::FilterMask:

List of all members.

Public Member Functions

void AddDebugLevel (const long int lv)
void AddDebugLevel (const std::string &name)
int ComputeIntPrecisionBits (int NumberOfBitsInInputData, int NumberOfBitsInTempData)
 compute the number of shiftable bits for int-from-float mask
void CreateFloatFilter ()
 create the float filter from the int filter
void CreateIntFilter (int rshift, int rshifth, int rshiftv)
 create the int filter from the float filter
bool DebugLevelIsSet (const std::string &name) const
bool DebugLevelIsSet (const long int lv) const
 FilterMask (const Matrix< FM_FLOAT > &kernel, bool ResetOtherType=FM_RESET_OTHER)
 calls Init
 FilterMask ()
 FilterMask (const FilterMask &mask)
 calls operator=
 FilterMask (const Vector< FM_INT > &horz, const Vector< FM_INT > &vert, int hrs, int vrs, bool ResetOtherType=FM_RESET_OTHER)
 calls Init
 FilterMask (const Matrix< FM_INT > &kernel, int rs, bool ResetOtherType=FM_RESET_OTHER)
 calls Init
 FilterMask (const Vector< FM_FLOAT > &horz, const Vector< FM_FLOAT > &vert, bool ResetOtherType=FM_RESET_OTHER)
 calls Init
int GetDebugLevel () const
std::ostream & GetDebugStream () const
void GetDebugStream (std::ostream &os) const
int GetHorizRightShift () const
 if separable, returns right shift after separated horizontal int filtering
const Matrix< FM_FLOAT > * GetKernelf () const
 returns pointer to float filter mask
const Matrix< FM_INT > * GetKerneli () const
 returns pointer to int filter mask
int GetKernelRightShift () const
 returns right shift applied to data after int mask filtering
const Vector< FM_FLOAT > * GetSepfh () const
 returns pointer to horiz float vector for sep.
const Vector< FM_FLOAT > * GetSepfv () const
 returns pointer to vertical float vector for sep.
const Vector< FM_INT > * GetSepih () const
 returns pointer to horizontal int vector for sep.
const Vector< FM_INT > * GetSepiv () const
 returns pointer to vertical int vector for sep.
void GetSize (int &hor, int &vert) const
 returns the size of the Kernel
int GetVertRightShift () const
 if separable, returns right shift after separated vertical int filtering
void Init (const Matrix< FM_FLOAT > &kernel, bool ResetOtherType=FM_RESET_OTHER)
 sets _fKernel and also calculates the best int approximation int _sKernel.
void Init (const Vector< FM_INT > &horz, const Vector< FM_INT > &vert, int hrs, int vrs, bool ResetOtherType=FM_RESET_OTHER)
 sets horz and vert vectors and their right shifts, _Separable is true, FM_FLOAT vectors are updated also
void Init (const Vector< FM_FLOAT > &horz, const Vector< FM_FLOAT > &vert, bool ResetOtherType=FM_RESET_OTHER)
 sets horz and vert vectors, _Separable is true, integer vectors are updated also
void Init (const Matrix< FM_INT > &kernel, int rs, bool ResetOtherType=FM_RESET_OTHER)
 sets _sKernel and also _fKernel.
bool IsSeparable () const
 checks if the kernel is separable
bool IsSize1x1 ()
 returns true if size is 1 by one
long int Name2DebugLevel (const std::string &name) const
 looks up a debuglevel in the internal map, returns 0 if not found
long int NewDebugLevel (const std::string &name)
 creates a new debuglevel
FilterMaskoperator= (const FilterMask &src)
 copy operator, copies ALL components
void PrintDebugLevel (std::ostream &os=std::cout) const
void RemoveDebugLevel (const long int lv)
void RemoveDebugLevel (const std::string &name)
void ResetFloatFilter ()
 fill float filter with zeros, same dim as int filter
void ResetIntFilter ()
 fill int filter with zeros, same dim as float filter
void SetDebugLevel (const std::string &name)
void SetDebugLevel (const long int lv)
void SetDebugStream (const std::ostream &os)
void SetZero ()
 reset data, all kernel to zero, separable to false
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels
void Transpose ()
 transposes the kernel (and adapts all dependent data)

Static Public Member Functions

static long int GetGlobalDebugLevel ()
static void SetGlobalDebugLevel (long int lev)

Protected Member Functions

long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel

Protected Attributes

Vector< FM_FLOAT > _fHoriz
 the filter mask in separated representation (floating point)
Matrix< FM_FLOAT > _fKernel
 the filter mask if we have a floating type convolution
Vector< FM_FLOAT > _fVert
int _HorizRightShift
int _KernelRightShift
 the shifts used for the integer filter masks
long int _liDebugLevel
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class
bool _Separable
 flag indicating if the 2 vectors or the matrix should be used as kernel representation
Vector< FM_INT > _sHoriz
 the filter mask in separated representation (integer)
Matrix< FM_INT > _sKernel
 the filter mask if we have a integer type convolution
std::map< std::string, long int > _String2Debuglevel
Vector< FM_INT > _sVert
int _VertRightShift

Static Protected Attributes

static std::ostream _zDebugStream
static long int GlobalDebugLevel = 0

Friends

BIASFilter_EXPORT std::ostream & operator<< (std::ostream &os, const FilterMask &fm)

Detailed Description

A filter mask (or a kernel) used for convolution.

When convolving an image with a FilterMask f, that mask is at first reflected at its symmetry center. Afterwards for each pixel x a weighted (by the entries of f) sum of the pixels around x is computed and written into the output image. In case of integer filtering, the result is shifted by the appropriate right shift.

You can define a filter mask by specifying either the float values or the int values and computing the other type. You may also set both manually, set the initalltypes flag to false for that. If your filtermask is separable you have to call the vector-init to define that.

Author:
skoglund, koeser, woelk 11/2004
Examples:

ExampleConvolution.cpp, and ExampleTrackerBaseInterface.cpp.

Definition at line 61 of file FilterMask.hh.


Constructor & Destructor Documentation

FilterMask::FilterMask ( )

Definition at line 32 of file FilterMask.cpp.

BIAS::FilterMask::FilterMask ( const FilterMask mask) [inline]

calls operator=

Definition at line 68 of file FilterMask.hh.

BIAS::FilterMask::FilterMask ( const Matrix< FM_INT > &  kernel,
int  rs,
bool  ResetOtherType = FM_RESET_OTHER 
) [inline]

calls Init

Parameters:
ResetOtherTypeif true, sets other filter entries to zero

Definition at line 73 of file FilterMask.hh.

BIAS::FilterMask::FilterMask ( const Matrix< FM_FLOAT > &  kernel,
bool  ResetOtherType = FM_RESET_OTHER 
) [inline]

calls Init

Definition at line 78 of file FilterMask.hh.

BIAS::FilterMask::FilterMask ( const Vector< FM_INT > &  horz,
const Vector< FM_INT > &  vert,
int  hrs,
int  vrs,
bool  ResetOtherType = FM_RESET_OTHER 
) [inline]

calls Init

Definition at line 83 of file FilterMask.hh.

BIAS::FilterMask::FilterMask ( const Vector< FM_FLOAT > &  horz,
const Vector< FM_FLOAT > &  vert,
bool  ResetOtherType = FM_RESET_OTHER 
) [inline]

calls Init

Definition at line 88 of file FilterMask.hh.


Member Function Documentation

void BIAS::Debug::AddDebugLevel ( const long int  lv) [inline, inherited]
void BIAS::Debug::AddDebugLevel ( const std::string &  name) [inline, inherited]

Definition at line 363 of file Debug.hh.

int FilterMask::ComputeIntPrecisionBits ( int  NumberOfBitsInInputData,
int  NumberOfBitsInTempData 
)

compute the number of shiftable bits for int-from-float mask

When you compute an int approximation of the float mask, you must avoid overflow. The weighted sum of the convolution is stored in the type CONV_INT, e.g. int, which means 31 bit range. The input data has typically 8 bit, so depending on the norm of the float filter mask, say 1.0 in this example, we can approximate a 0.3 entry in the float mask by and int entry = 0.3*(1<<(31-8))). This function computes the maximum possible shift.

Parameters:
NumberOfBitsInInputDatatypically sizeof(InputImageType)*8
NumberOfBitsInTempDatatypically sizeof(CONV_INT)*8-1
Returns:
number of possible shifts in int mask approximation

Definition at line 211 of file FilterMask.cpp.

Referenced by BIAS::HessianGauss< InputStorageType, OutputStorageType >::_CalculateKernels(), BIAS::GradientGaussAsymmetric< InputStorageType, OutputStorageType >::_CalculateKernels(), and BIAS::GradientGauss< InputStorageType, OutputStorageType >::_CalculateKernels().

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( ) [inline, protected, inherited]

returns the next available debuglevel

Author:
woelk 09/2006

Definition at line 522 of file Debug.hh.

void FilterMask::CreateFloatFilter ( )
void FilterMask::CreateIntFilter ( int  rshift,
int  rshifth,
int  rshiftv 
)
bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const [inline, inherited]
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const [inline, inherited]

Definition at line 351 of file Debug.hh.

int BIAS::Debug::GetDebugLevel ( ) const [inline, inherited]
std::ostream& BIAS::Debug::GetDebugStream ( ) const [inline, inherited]

Definition at line 406 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const [inline, inherited]

Definition at line 415 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( ) [inline, static, inherited]

Definition at line 432 of file Debug.hh.

int BIAS::FilterMask::GetHorizRightShift ( ) const [inline]

if separable, returns right shift after separated horizontal int filtering

Definition at line 148 of file FilterMask.hh.

const Matrix<FM_FLOAT>* BIAS::FilterMask::GetKernelf ( ) const [inline]
const Matrix<FM_INT>* BIAS::FilterMask::GetKerneli ( ) const [inline]

returns pointer to int filter mask

Definition at line 112 of file FilterMask.hh.

int BIAS::FilterMask::GetKernelRightShift ( ) const [inline]

returns right shift applied to data after int mask filtering

Definition at line 143 of file FilterMask.hh.

const Vector<FM_FLOAT>* BIAS::FilterMask::GetSepfh ( ) const [inline]
const Vector<FM_FLOAT>* BIAS::FilterMask::GetSepfv ( ) const [inline]
const Vector<FM_INT>* BIAS::FilterMask::GetSepih ( ) const [inline]

returns pointer to horizontal int vector for sep.

filtering

Definition at line 120 of file FilterMask.hh.

const Vector<FM_INT>* BIAS::FilterMask::GetSepiv ( ) const [inline]

returns pointer to vertical int vector for sep.

filtering

Definition at line 124 of file FilterMask.hh.

void BIAS::FilterMask::GetSize ( int &  hor,
int &  vert 
) const [inline]

returns the size of the Kernel

Author:
woelk 05/2005

Definition at line 201 of file FilterMask.hh.

int BIAS::FilterMask::GetVertRightShift ( ) const [inline]

if separable, returns right shift after separated vertical int filtering

Definition at line 153 of file FilterMask.hh.

void FilterMask::Init ( const Vector< FM_FLOAT > &  horz,
const Vector< FM_FLOAT > &  vert,
bool  ResetOtherType = FM_RESET_OTHER 
)

sets horz and vert vectors, _Separable is true, integer vectors are updated also

Definition at line 65 of file FilterMask.cpp.

void FilterMask::Init ( const Matrix< FM_FLOAT > &  kernel,
bool  ResetOtherType = FM_RESET_OTHER 
)

sets _fKernel and also calculates the best int approximation int _sKernel.

_Separable is set to false.

Definition at line 47 of file FilterMask.cpp.

void FilterMask::Init ( const Vector< FM_INT > &  horz,
const Vector< FM_INT > &  vert,
int  hrs,
int  vrs,
bool  ResetOtherType = FM_RESET_OTHER 
)

sets horz and vert vectors and their right shifts, _Separable is true, FM_FLOAT vectors are updated also

Definition at line 54 of file FilterMask.cpp.

void FilterMask::Init ( const Matrix< FM_INT > &  kernel,
int  rs,
bool  ResetOtherType = FM_RESET_OTHER 
)

sets _sKernel and also _fKernel.

_Separable is set to false

Examples:
ExampleConvolution.cpp.

Definition at line 37 of file FilterMask.cpp.

Referenced by BIAS::Tracker< StorageType, CalculationType >::Vector2FilterMask_().

bool BIAS::FilterMask::IsSeparable ( ) const [inline]
bool BIAS::FilterMask::IsSize1x1 ( ) [inline]

returns true if size is 1 by one

Author:
woelk 05/2005

Definition at line 196 of file FilterMask.hh.

long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const [inline, inherited]

looks up a debuglevel in the internal map, returns 0 if not found

Author:
woelk 09/2006

Definition at line 455 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name) [inline, inherited]
FilterMask & FilterMask::operator= ( const FilterMask src)

copy operator, copies ALL components

Definition at line 75 of file FilterMask.cpp.

References _fHoriz, _fKernel, _fVert, _HorizRightShift, _KernelRightShift, _Separable, _sHoriz, _sKernel, _sVert, and _VertRightShift.

void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const [inline, inherited]

Definition at line 384 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const long int  lv) [inline, inherited]

Definition at line 370 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name) [inline, inherited]

Definition at line 377 of file Debug.hh.

void FilterMask::ResetFloatFilter ( )

fill float filter with zeros, same dim as int filter

Definition at line 152 of file FilterMask.cpp.

void FilterMask::ResetIntFilter ( )

fill int filter with zeros, same dim as float filter

Definition at line 171 of file FilterMask.cpp.

void BIAS::Debug::SetDebugLevel ( const std::string &  name) [inline, inherited]

Definition at line 326 of file Debug.hh.

void BIAS::Debug::SetDebugLevel ( const long int  lv) [inline, inherited]
void BIAS::Debug::SetDebugStream ( const std::ostream &  os) [inline, inherited]

Definition at line 399 of file Debug.hh.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev) [inline, static, inherited]

Definition at line 425 of file Debug.hh.

void BIAS::FilterMask::SetZero ( ) [inline]

reset data, all kernel to zero, separable to false

Definition at line 187 of file FilterMask.hh.

Referenced by BIAS::Convolution< InputStorageType, OutputStorageType >::Convolution().

void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const [inline, inherited]

prints all internally known debuglevels

Author:
woelk 09/2006

Definition at line 497 of file Debug.hh.

void FilterMask::Transpose ( )

Friends And Related Function Documentation

BIASFilter_EXPORT std::ostream& operator<< ( std::ostream &  os,
const FilterMask fm 
) [friend]

Member Data Documentation

Vector<FM_FLOAT> BIAS::FilterMask::_fHoriz [protected]

the filter mask in separated representation (floating point)

Definition at line 214 of file FilterMask.hh.

Referenced by operator=().

Matrix<FM_FLOAT> BIAS::FilterMask::_fKernel [protected]

the filter mask if we have a floating type convolution

Definition at line 210 of file FilterMask.hh.

Referenced by operator=().

Vector<FM_FLOAT> BIAS::FilterMask::_fVert [protected]

Definition at line 214 of file FilterMask.hh.

Referenced by operator=().

Definition at line 219 of file FilterMask.hh.

Referenced by operator=().

the shifts used for the integer filter masks

Definition at line 219 of file FilterMask.hh.

Referenced by operator=().

long int BIAS::Debug::_liDebugLevel [protected, inherited]

Definition at line 511 of file Debug.hh.

Referenced by BIAS::ImageBase::operator=(), and BIAS::Debug::operator=().

long int BIAS::Debug::_liNextDebugLevel [protected, inherited]

new concept, debuglevel are managed here in the debug class

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

bool BIAS::FilterMask::_Separable [protected]

flag indicating if the 2 vectors or the matrix should be used as kernel representation

Definition at line 217 of file FilterMask.hh.

Referenced by operator=().

Vector<FM_INT> BIAS::FilterMask::_sHoriz [protected]

the filter mask in separated representation (integer)

Definition at line 212 of file FilterMask.hh.

Referenced by operator=().

Matrix<FM_INT> BIAS::FilterMask::_sKernel [protected]

the filter mask if we have a integer type convolution

Definition at line 208 of file FilterMask.hh.

Referenced by operator=().

std::map<std::string, long int> BIAS::Debug::_String2Debuglevel [protected, inherited]

Definition at line 518 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

Vector<FM_INT> BIAS::FilterMask::_sVert [protected]

Definition at line 212 of file FilterMask.hh.

Referenced by operator=().

Definition at line 219 of file FilterMask.hh.

Referenced by operator=().

std::ostream BIAS::Debug::_zDebugStream [static, protected, inherited]

Definition at line 512 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

long int BIAS::Debug::GlobalDebugLevel = 0 [static, protected, inherited]

Definition at line 514 of file Debug.hh.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends