Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ellipse.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 #ifndef ELLIPSE_HH
25 #define ELLIPSE_HH
26 
27 #include "bias_config.h"
28 #include <Base/Math/Matrix2x2.hh>
29 
30 
31 namespace BIAS {
32 
33  /** Ellipse in 2D with dfifferent representations.
34  * \author bartczak 06/2011
35  **/
36 class BIASGeometry_EXPORT Ellipse
37 {
38 public:
39  Ellipse();
40  /** Initialisation via affine transformation. **/
41  void SetParametric(const double scaleX,
42  const double scaleY,
43  const double rotAngleDeg,
44  const double centerX,
45  const double centerY);
46 
47  /** Uses quadric represenation. **/
48  void SetImplicit(const BIAS::Matrix2x2<double>& implicitForm,
49  const double centerX, const double centerY);
50 
51  /** Uses quadric represenation and adapts size of ellipse. **/
52  void SetImplicit(const BIAS::Matrix2x2<double>& implicitForm,
53  const double F,
54  const double centerX, const double centerY);
55 
56  /** Assumes ellipse to be a certain iso value line on a
57  * 2D gaussian without cross correlation (no rotation).
58  * Gaussian is g(x) = 1/N exp(-0.5 x^t Q x).
59  * This ellipse will be Q = I*(1/sigmaX^2 , 1/sigmaY^2)
60  * Ellipse calculated has the implicit form:
61  * x^t Q x - F = 0.
62  **/
63  void SetGaussianFilterRange(const double& sigmaX,
64  const double& sigmaY,
65  const double F = 9.0);
66 
67  void CalculateAxisAlignedBoundingBox(double& minX, double& minY,
68  double& maxX, double& maxY) const;
69 
70 
71  BIAS::Matrix2x2<double> ReturnImplicitRepresentation() const;
72  BIAS::Matrix2x2<double> ReturnParametricTransformation() const;
73 
74 private:
75  //different representations
76 
77  double centerX_;
78  double centerY_;
79  BIAS::Matrix2x2<double> parametricTransform_;
80 
81  void CalcImplicitFromParameteric_();
82  void CalcParametericFromImplicit_();
83 
84 
85  //implicit representation
86  BIAS::Matrix2x2<double> implicitForm_;
87 
88 
89 };
90 
91 }
92 #endif // ELLIPSE_HH
Ellipse in 2D with dfifferent representations.
Definition: Ellipse.hh:36