Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
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:

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

Static Public Member Functions

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

Protected Member Functions

long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 

Protected Attributes

Vector< FM_FLOAT > _fHoriz
 the filter mask in separated representation (floating point) More...
 
Matrix< FM_FLOAT > _fKernel
 the filter mask if we have a floating type convolution More...
 
Vector< FM_FLOAT > _fVert
 
int _HorizRightShift
 
int _KernelRightShift
 the shifts used for the integer filter masks More...
 
long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
bool _Separable
 flag indicating if the 2 vectors or the matrix should be used as kernel representation More...
 
Vector< FM_INT > _sHoriz
 the filter mask in separated representation (integer) More...
 
Matrix< FM_INT > _sKernel
 the filter mask if we have a integer type convolution More...
 
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)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 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::GradientGaussAsymmetric< InputStorageType, OutputStorageType >::_CalculateKernels(), BIAS::HessianGauss< InputStorageType, OutputStorageType >::_CalculateKernels(), and BIAS::GradientGauss< InputStorageType, OutputStorageType >::_CalculateKernels().

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 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
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 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 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_().

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

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
inlineinherited

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

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
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
inlineinherited

Definition at line 383 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 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 long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 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
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 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=().

int BIAS::FilterMask::_HorizRightShift
protected

Definition at line 219 of file FilterMask.hh.

Referenced by operator=().

int BIAS::FilterMask::_KernelRightShift
protected

the shifts used for the integer filter masks

Definition at line 219 of file FilterMask.hh.

Referenced by operator=().

long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

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

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 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
protectedinherited

Definition at line 517 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=().

int BIAS::FilterMask::_VertRightShift
protected

Definition at line 219 of file FilterMask.hh.

Referenced by operator=().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

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

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.


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