Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ContourBSplineShapeMatrix.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 __BIAS_CONTOURBSPLINESHAPEMATRIX_HH_
26 #define __BIAS_CONTOURBSPLINESHAPEMATRIX_HH_
27 
28 #include <list>
29 
30 #include <Base/Math/Matrix.hh>
31 #include <Base/Math/Vector.hh>
32 
33 #include "ContourBSplineData.hh"
34 
35 namespace BIAS{
36 
37  /**
38  @class ContourBSplineShapeMatrix
39  @brief data object which holds a shape matrix or regularisation matrix
40  for a b-spline curve; could be shared by some ContourBSpline
41  objects
42 
43  Objects of this class represents eithe a shape-matrix (invariant as well)
44  or a regularisation matrix. These matrices are only needed if a
45  fitting of a B-Spline curve is used. If you use copys of a BSplineContour
46  object they share this ContourBSplineMatrix object to save memory.
47 
48  A ContourBSplineShapeMatrix object is generated transparently
49  by using Set[Sub]ShapeSpace...(...) or ComputeRegularisationMatrix() of
50  the ContourBSpline object. These methods call Set[Sub]ShapeSpace...(...)
51  or ComputeRegularisationMatrix(...) of this class. The pointer to this
52  object gets returned.
53 
54  Copys of a B-Spline curve share this object, the pointer to this
55  object gets copied and the reference counter increased.
56 
57  If a ContourBSpline objects gets destroyed it calls the Unregister()
58  method of its ContourBSplineShapeMatrix objects. This decreases the
59  reference counter and destroys these objects, if the reference counter is
60  zero.
61  @ingroup g_feature
62 
63  */
64  class ContourBSplineShapeMatrix : public BIAS::Matrix<double>{
65  friend class ContourBSpline;
66  public:
67 
68  /**
69  * @brief standard constructor
70  */
72 
73  /**
74  * @brief destructor
75  *
76  * Calls Unregister() method to decrease reference counter and destroy
77  * object if its reference counter is zero.
78  *
79  */
81  Unregister();
82  };
83 
84  /**
85  * @brief a BSplineContour object uses this method to unregister itself
86  * from using this object
87  *
88  * Decreases reference counter and destroys object if reference counter
89  * is zero.
90  *
91  */
92  inline void Unregister();
93 
94  /**
95  * @brief generates a new shape-matrix (invariant as well) as
96  * ContourBSplineShapeMatrix object and returns a pointer to it
97  * @param[in] matrix shape-matrix
98  *
99  */
101  const BIAS::Matrix<double>& matrix);
102 
103  /**
104  * @brief generates a new shape-matrix (invariant as well) as
105  * ContourBSplineShapeMatrix object and returns a pointer to it
106  *
107  * @param[in] numBasePolynoms number of base polynoms of curve - equal
108  * to number of control points of the curve
109  *
110  * Uses parameter "numBasePolynoms" to generate a identity matrix of
111  * size 2*"numBasePolynoms".
112  *
113  */
115  const unsigned int numBasePolynoms);
116 
117  /**
118  * @brief generates a new shape-matrix (invariant as well) as
119  * ContourBSplineShapeMatrix object and returns a pointer to it
120  *
121  * @param[in] numBasePolynoms number of base polynoms of curve - equal
122  * to number of control points of the curve
123  * @param[in] Q vector of control points
124  *
125  * Builds a shape-matrix (invariant as well) of euclidian similarities.
126  * Size of matrix is 2*numBasePolynoms x 4.
127  *
128  * Confer to "Active Contours" chapter 4.
129  */
131  const unsigned int numBasePolynoms,
132  const BIAS::Vector<double>& Q);
133 
134  /**
135  * @brief generates a new shape-matrix (invariant as well) as
136  * ContourBSplineShapeMatrix object and returns a pointer to it
137  *
138  * @param[in] numBasePolynoms number of base polynoms of curve - equal
139  * to number of control points of the curve
140  * @param[in] Q vector of control points
141  *
142  * Builds a shape-matrix (invariant as well) of plana affine
143  * transformations. Size of matrix is 2*numBasePolynoms x 6.
144  *
145  * Confer to "Active Contours" chapter 4.
146  */
148  const unsigned int numBasePolynoms,
149  const BIAS::Vector<double>& Q);
150 
151  /**
152  * @brief generates a new invariant shape-matrix as
153  * ContourBSplineShapeMatrix object and returns a pointer to it
154  *
155  * @param[in] shapeSpace shape-matrix (not invariant!)
156  *
157  * Builds a invariant shape-matrix which is zero. Has same size like
158  * the parameter shape-matrix.
159  *
160  */
162  ContourBSplineShapeMatrix* shapeSpace);
163 
164  /**
165  * @brief generates a new regularisation matrix as
166  * ContourBSplineShapeMatrix object and returns pointer to it
167  *
168  * @param[in] data data object of a B-Spline curve
169  * @param[in] shapeSpace shape-matrix
170  * @param[in] subShapeSpace invariant shape-matrix
171  *
172  * Computes the regularisation matrix needed for fitting a B-Spline
173  * curve.
174  */
176  ContourBSplineData* data,
177  ContourBSplineShapeMatrix* shapeSpace,
178  ContourBSplineShapeMatrix* subShapeSpace);
179 
180 
181  //! list of all pointers to ContourBSplineShapeMatrix objects
182  static std::list<ContourBSplineShapeMatrix*> pntr_;
183 
184  //! reference counter - for handling unregister
185  unsigned int reference_; //reference counter
186 
187  };//class
188 
190  reference_--;
191  if(reference_==0){
192  pntr_.remove(this);
193  delete this;
194  }
195  }
196 
197 }//namespace BIAS
198 #endif
void Unregister()
a BSplineContour object uses this method to unregister itself from using this object ...
data object which holds a shape matrix or regularisation matrix for a b-spline curve; could be shared...
unsigned int reference_
reference counter - for handling unregister
data object which holds all infomations of a B-Spline curve (ContourBSpline); its shared by B-Spline ...
static ContourBSplineShapeMatrix * ComputeRegularisationMatrix(ContourBSplineData *data, ContourBSplineShapeMatrix *shapeSpace, ContourBSplineShapeMatrix *subShapeSpace)
generates a new regularisation matrix as ContourBSplineShapeMatrix object and returns pointer to it ...
static ContourBSplineShapeMatrix * SetShapeSpacePlanarAffin(const unsigned int numBasePolynoms, const BIAS::Vector< double > &Q)
generates a new shape-matrix (invariant as well) as ContourBSplineShapeMatrix object and returns a po...
ContourBSplineShapeMatrix()
standard constructor
static ContourBSplineShapeMatrix * SetShapeSpaceMatrix(const BIAS::Matrix< double > &matrix)
generates a new shape-matrix (invariant as well) as ContourBSplineShapeMatrix object and returns a po...
matrix class with arbitrary size, indexing is row major.
static ContourBSplineShapeMatrix * SetShapeSpaceIdentity(const unsigned int numBasePolynoms)
generates a new shape-matrix (invariant as well) as ContourBSplineShapeMatrix object and returns a po...
static ContourBSplineShapeMatrix * SetSubShapeSpaceZero(ContourBSplineShapeMatrix *shapeSpace)
generates a new invariant shape-matrix as ContourBSplineShapeMatrix object and returns a pointer to i...
static std::list< ContourBSplineShapeMatrix * > pntr_
list of all pointers to ContourBSplineShapeMatrix objects
static ContourBSplineShapeMatrix * SetShapeSpaceEuclidian(const unsigned int numBasePolynoms, const BIAS::Vector< double > &Q)
generates a new shape-matrix (invariant as well) as ContourBSplineShapeMatrix object and returns a po...