Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Parametrization.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __Parametrization_hh__
26 #define __Parametrization_hh__
27 
28 #include <Base/Common/BIASpragmaStart.hh>
29 
30 #include <vector>
31 
32 #include "FMatrix.hh"
33 #include "HMatrix.hh"
34 #include "EMatrix.hh"
35 
36 namespace BIAS
37 {
38 
39 #define NUM_PARAM_ESSENTIAL 5
40 #define MINIMUM_ROTATION 1e-6
41 
42 /** This class is used for parametrizing F- and H-matrices, generally for
43  optimization purposes.
44  Be sure to use one and the same instance of this class for parametrization
45  and deparametrization of your matrix!!!
46  This parametrization is needed during the MotionModelSelection which
47  is part of my diploma thesis.
48  @author Matthias Dunda
49  @date 09 2003 */
50  class BIASGeometry_EXPORT Parametrization
51  {
52  public:
54  ~Parametrization();
55 
56  /** parametizes an F-matrix to seven parameters
57  @return true on success, false on error
58  @author mdunda 09 2003 */
59  bool FMatrixToParams( const BIAS::FMatrix &Mat,
60  std::vector<double> &Params );
61 
62  /** composes an F-matrix from the seven given parameters
63  The deparametrization only works with the previously parametized
64  values of 'FMatrixToParams', because some internally stored
65  parameters are important for the correct composition.
66  @return true on success, false on error
67  @author mdunda 09 2003 */
68  bool ParamsToFMatrix( BIAS::FMatrix &Mat,
69  const std::vector<double> &Params );
70 
71  /** parametizes an H-matrix to eight parameters
72  @return true on success, false on error
73  @author mdunda 09 2003 */
74  bool HMatrixToParams( const BIAS::HMatrix &Mat,
75  std::vector<double> &Params );
76 
77  /** composes an H-matrix from the seven given parameters
78  @return true on success, false on error
79  @author mdunda 09 2003 */
80  bool ParamsToHMatrix( BIAS::HMatrix &Mat,
81  const std::vector<double> &Params );
82 
83  /** parametizes an essential-matrix to five parameters
84  @return true on success, false on error
85  @author frahm 03 2004 */
86  static bool EMatrixToParams( BIAS::EMatrix &Mat,
87  Vector<double> &Params,
88  std::vector<BIAS::HomgPoint2D> &inlier1,
89  std::vector<BIAS::HomgPoint2D> &inlier2,
90  bool UseQuaternion = false);
91 
92  /** composes an essential-matrix from the five given parameters
93  @return true on success, false on error
94  @author frahm 03 2004 */
95  static bool ParamsToEMatrix( BIAS::EMatrix &Mat,
96  const Vector<double> &Params,
97  bool UseQuaternion = false);
98 
99  inline double GetFScaling() { return Fscale_; }
100  inline double GetHScaling() { return Hscale_; }
101 
102  protected:
103  // protected attributes for F-matrix parametrization
105  std::vector<double> FParams_;
106 
107  /* the next variables hold the position of the element in the F matrix
108  that was used for the normalization */
109  int Frow_,Fcol_;
110 
111  // protected attributes for H-matrix parametrization
113  std::vector<double> HParams_;
114 
115  // protected methods (helpers)
116  /** Find the biggest absolute entry of the upper left 2x2 submatrix of
117  the internally stored F matrix member.
118  The position of this element is stored internally and used for
119  the composition of the F matrix in ParamsToFMatrix.
120  @return value of the entry with biggest absolute value
121  @author mdunda 09 2003 */
122  double GetBiggestAbsEntry();
123  double Fscale_;
124  double Hscale_;
125  }; // class Parametrization
126 } // namespace BIAS
127 
128 #include <Base/Common/BIASpragmaEnd.hh>
129 
130 #endif /* __Parametrization_hh__ */
131 
a 3x3 Matrix describing projective transformations between planes
Definition: HMatrix.hh:39
std::vector< double > HParams_
This class is used for parametrizing F- and H-matrices, generally for optimization purposes...
class representing an Essential matrix
Definition: EMatrix.hh:52
class representing a Fundamental matrix
Definition: FMatrix.hh:46
std::vector< double > FParams_