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 | List of all members
BIAS::ImageAlignment Class Reference

Inverse Compositional Image Alignment ("Registration") More...

#include <Matcher2D/ImageAlignment.hh>

+ Inheritance diagram for BIAS::ImageAlignment:
+ Collaboration diagram for BIAS::ImageAlignment:

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
int Align (const PyramidImage< float > &I1, const PyramidImage< float > &I2, Vector< double > &params, Matrix< double > &Cov, int PyramidLevel=-1)
 aligns image1 with image2 with respect to parameters params More...
 
int AutoAlign (const PyramidImage< float > &I1, const PyramidImage< float > &I2, Vector< double > &params, Matrix< double > &Cov)
 aligns image1 with image2 with respect to parameters params, scale space tracking is used recursively until maximum resolution reached. More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
void GetLastBrightnessChange (double &scale, double &shift)
 return relative affine transform between i1 and i2 if AffineBrightnessInvariance was active More...
 
int GetMaxIterations ()
 
float GetMaxUpdate ()
 
 ImageAlignment ()
 
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...
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetAffineBrightnessInvariance (bool bi)
 enable brightness variance and offset invariant computation More...
 
void SetAlignmentPixelsRectangular (const LocalAffineFrame &LAF, int numberOfPixels=-1)
 choose any rectangular tracking region and resolution More...
 
void SetDampening (const double &dampening)
 adds a dampening d to hessian's diag More...
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetIntensitySigma (const double &sigma)
 set expected standard deviation for grey value noise More...
 
void SetLineSearch (const double &lineSearch)
 enable/disable and set step width for line search: <=0 disables, 0.1 or 0.5 may be good values. More...
 
void SetMaxIterations (const int maxiter)
 number of iterations, before the system stops unsuccessfully More...
 
void SetTextureTransform (const TextureTransform &T)
 pass object type which holds texture transform More...
 
void SetUpdateThreshold (const double maxerr)
 if a step smaller (norm L2) than this is taken, convergence is declared and the system finishes More...
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
int StrictPyramidAlign (const PyramidImage< float > &I1, const PyramidImage< float > &I2, Vector< double > &params, Matrix< double > &Cov)
 aligns image1 with image2 with respect to parameters params, traditional pyramid based alignment is used, mainly for comparison reasons. More...
 
 ~ImageAlignment ()
 

Static Public Member Functions

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

Protected Member Functions

int CheckConvergence_ (const Vector< double > &params, const Matrix< double > &Cov, const double &pixelAccuracy=0.3)
 check for given cov and params, whether control points move more than pixelAccuracy More...
 
long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 

Protected Attributes

long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
std::map< std::string, long int > _String2Debuglevel
 
std::vector< bool > active_
 
bool AffineBrightnessInvariance_
 compute brightness "invariant" More...
 
std::vector< HomgPoint2DControlPositions_
 
double Dampening_
 adds a dampening to hessian's diag: >=0: d, <0 d*largest eigvalue More...
 
double dev1_
 
double dev2_
 
std::vector< HomgPoint2DImagePositions_
 
double intensitySigma_
 how much noise is expected on intensity values More...
 
int iterationDebug_
 internal counter for numbering debug images More...
 
double LineSearch_
 if error is not reduced in one step, linesearch times this step is tried set to <=0 to disable line search More...
 
int MaxIterations_
 iteration stops after More...
 
float MaxUpdate_
 iteration stops if parameter update is less than More...
 
double mean1_
 mean and std deviation of image patch More...
 
double mean2_
 
std::vector< Vector< double > > SteepestDescentImages_
 
TextureTransformT_
 the warp model More...
 
std::vector< Vector2< double > > TemplateGradients_
 
std::vector< double > TemplateGreyValues_
 gradients and grey values from image 1 More...
 
std::vector< HomgPoint2DTemplatePositions_
 
std::vector< double > TemplateScales_
 

Static Protected Attributes

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

Detailed Description

Inverse Compositional Image Alignment ("Registration")

This class implements generic inverse compositional image alignment as proposed by Baker and Matthews in "Lucas-Kanade 20 years on". The model for which you estimate the parameters must be of type TextureTransform (e.g. affine, homography, displacement, camera pose, calibration, ...).

The key idea is that the required inversion of the hessian and the incorporation of the gradients are not recomputed per iteration in this formulation as opposed to the standard KLT.

Author
koeser 01/2008
Examples:
EvaluateAlignment.cpp, and ExampleAlignment.cpp.

Definition at line 61 of file ImageAlignment.hh.

Constructor & Destructor Documentation

BIAS::ImageAlignment::ImageAlignment ( )

Definition at line 42 of file ImageAlignment.cpp.

BIAS::ImageAlignment::~ImageAlignment ( )
inline

Definition at line 65 of file ImageAlignment.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 BIAS::ImageAlignment::Align ( const PyramidImage< float > &  I1,
const PyramidImage< float > &  I2,
Vector< double > &  params,
Matrix< double > &  Cov,
int  PyramidLevel = -1 
)
int BIAS::ImageAlignment::AutoAlign ( const PyramidImage< float > &  I1,
const PyramidImage< float > &  I2,
Vector< double > &  params,
Matrix< double > &  Cov 
)

aligns image1 with image2 with respect to parameters params, scale space tracking is used recursively until maximum resolution reached.

Requires correct Cov as input.

Examples:
EvaluateAlignment.cpp.

Definition at line 923 of file ImageAlignment.cpp.

References TNT::Matrix< T >::num_cols(), TNT::Matrix< T >::num_rows(), TNT::Vector< T >::size(), and BIAS::Matrix< T >::Trace().

int BIAS::ImageAlignment::CheckConvergence_ ( const Vector< double > &  params,
const Matrix< double > &  Cov,
const double &  pixelAccuracy = 0.3 
)
protected

check for given cov and params, whether control points move more than pixelAccuracy

Definition at line 1123 of file ImageAlignment.cpp.

References BIAS::Matrix< T >::Transpose().

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

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.

void BIAS::ImageAlignment::GetLastBrightnessChange ( double &  scale,
double &  shift 
)
inline

return relative affine transform between i1 and i2 if AffineBrightnessInvariance was active

i2 = scale * i1 + shift

Examples:
ExampleAlignment.cpp.

Definition at line 127 of file ImageAlignment.hh.

int BIAS::ImageAlignment::GetMaxIterations ( )
inline

Definition at line 109 of file ImageAlignment.hh.

float BIAS::ImageAlignment::GetMaxUpdate ( )
inline

Definition at line 111 of file ImageAlignment.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
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 BIAS::ImageAlignment::SetAffineBrightnessInvariance ( bool  bi)
inline

enable brightness variance and offset invariant computation

Examples:
ExampleAlignment.cpp.

Definition at line 105 of file ImageAlignment.hh.

void BIAS::ImageAlignment::SetAlignmentPixelsRectangular ( const LocalAffineFrame LAF,
int  numberOfPixels = -1 
)

choose any rectangular tracking region and resolution

The localaffineframe determines the shape, scale and orientation of the rectangular region used for tracking. The numberofpixelsis a windowsize, e.g. if you pass 9, a 9x9 grid will be used for tracking If you pass -1, each pixel is used for tracking

Examples:
EvaluateAlignment.cpp, and ExampleAlignment.cpp.

Definition at line 874 of file ImageAlignment.cpp.

References BIAS::Matrix2x2< T >::det(), BIAS::LocalAffineFrame::GetA(), BIAS::HomgPoint2D, and BIAS::LocalAffineFrame::LocalToGlobal().

void BIAS::ImageAlignment::SetDampening ( const double &  dampening)
inline

adds a dampening d to hessian's diag

Parameters
dampening,:>=0: d, <0 -d*largest eigvalue
Examples:
EvaluateAlignment.cpp, and ExampleAlignment.cpp.

Definition at line 140 of file ImageAlignment.hh.

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::ImageAlignment::SetIntensitySigma ( const double &  sigma)
inline

set expected standard deviation for grey value noise

This is important if maximum a posteriori-estimation is desired and you provide a correctly scaled prior cov for the warp parameters. Pixels which have smaller gradient than this are rejected.

Definition at line 149 of file ImageAlignment.hh.

void BIAS::ImageAlignment::SetLineSearch ( const double &  lineSearch)
inline

enable/disable and set step width for line search: <=0 disables, 0.1 or 0.5 may be good values.

1.0 would mean original step

Definition at line 134 of file ImageAlignment.hh.

void BIAS::ImageAlignment::SetMaxIterations ( const int  maxiter)
inline

number of iterations, before the system stops unsuccessfully

Examples:
EvaluateAlignment.cpp, and ExampleAlignment.cpp.

Definition at line 96 of file ImageAlignment.hh.

void BIAS::ImageAlignment::SetTextureTransform ( const TextureTransform T)
inline

pass object type which holds texture transform

Examples:
EvaluateAlignment.cpp, and ExampleAlignment.cpp.

Definition at line 90 of file ImageAlignment.hh.

References BIAS::TextureTransform::Clone().

void BIAS::ImageAlignment::SetUpdateThreshold ( const double  maxerr)
inline

if a step smaller (norm L2) than this is taken, convergence is declared and the system finishes

Examples:
EvaluateAlignment.cpp, and ExampleAlignment.cpp.

Definition at line 101 of file ImageAlignment.hh.

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.

int BIAS::ImageAlignment::StrictPyramidAlign ( const PyramidImage< float > &  I1,
const PyramidImage< float > &  I2,
Vector< double > &  params,
Matrix< double > &  Cov 
)

aligns image1 with image2 with respect to parameters params, traditional pyramid based alignment is used, mainly for comparison reasons.

Can be used also if Cov is totally unknown.

Examples:
ExampleAlignment.cpp.

Definition at line 1043 of file ImageAlignment.cpp.

References TNT::Matrix< T >::num_cols(), TNT::Matrix< T >::num_rows(), BIAS::PyramidImageInterface< StorageType >::size(), TNT::Vector< T >::size(), and BIAS::Matrix< T >::Trace().

Member Data Documentation

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=().

std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

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

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

Definition at line 511 of file Debug.hh.

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

std::vector<bool> BIAS::ImageAlignment::active_
protected

Definition at line 200 of file ImageAlignment.hh.

bool BIAS::ImageAlignment::AffineBrightnessInvariance_
protected

compute brightness "invariant"

Definition at line 175 of file ImageAlignment.hh.

std::vector<HomgPoint2D> BIAS::ImageAlignment::ControlPositions_
protected

Definition at line 196 of file ImageAlignment.hh.

double BIAS::ImageAlignment::Dampening_
protected

adds a dampening to hessian's diag: >=0: d, <0 d*largest eigvalue

Definition at line 172 of file ImageAlignment.hh.

double BIAS::ImageAlignment::dev1_
protected

Definition at line 189 of file ImageAlignment.hh.

double BIAS::ImageAlignment::dev2_
protected

Definition at line 189 of file ImageAlignment.hh.

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

Definition at line 513 of file Debug.hh.

std::vector<HomgPoint2D> BIAS::ImageAlignment::ImagePositions_
protected

Definition at line 198 of file ImageAlignment.hh.

double BIAS::ImageAlignment::intensitySigma_
protected

how much noise is expected on intensity values

Definition at line 182 of file ImageAlignment.hh.

int BIAS::ImageAlignment::iterationDebug_
protected

internal counter for numbering debug images

Definition at line 203 of file ImageAlignment.hh.

double BIAS::ImageAlignment::LineSearch_
protected

if error is not reduced in one step, linesearch times this step is tried set to <=0 to disable line search

Definition at line 179 of file ImageAlignment.hh.

int BIAS::ImageAlignment::MaxIterations_
protected

iteration stops after

Definition at line 166 of file ImageAlignment.hh.

float BIAS::ImageAlignment::MaxUpdate_
protected

iteration stops if parameter update is less than

Definition at line 169 of file ImageAlignment.hh.

double BIAS::ImageAlignment::mean1_
protected

mean and std deviation of image patch

Definition at line 189 of file ImageAlignment.hh.

double BIAS::ImageAlignment::mean2_
protected

Definition at line 189 of file ImageAlignment.hh.

std::vector<Vector<double> > BIAS::ImageAlignment::SteepestDescentImages_
protected

Definition at line 199 of file ImageAlignment.hh.

TextureTransform* BIAS::ImageAlignment::T_
protected

the warp model

Definition at line 186 of file ImageAlignment.hh.

std::vector<Vector2<double> > BIAS::ImageAlignment::TemplateGradients_
protected

Definition at line 193 of file ImageAlignment.hh.

std::vector<double> BIAS::ImageAlignment::TemplateGreyValues_
protected

gradients and grey values from image 1

Definition at line 192 of file ImageAlignment.hh.

std::vector<HomgPoint2D> BIAS::ImageAlignment::TemplatePositions_
protected

Definition at line 195 of file ImageAlignment.hh.

std::vector<double> BIAS::ImageAlignment::TemplateScales_
protected

Definition at line 194 of file ImageAlignment.hh.


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