]> Creatis software - clitk.git/blob - tools/clitkEllipse.h
Initial revision
[clitk.git] / tools / clitkEllipse.h
1 /*=========================================================================
2                                                                                 
3   Program:   clitk
4   Module:    $RCSfile: clitkEllipse.h,v $
5   Language:  C++
6   Date:      $Date: 2010/01/06 13:31:56 $
7   Version:   $Revision: 1.1 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                              
17 =========================================================================*/
18
19 #ifndef CLITKELLIPSE_H
20 #define CLITKELLIPSE_H
21
22 #include "clitkCommon.h"
23 #include "clitkSignal.h"
24 #include "itkVector.h"
25 #include <vnl/algo/vnl_generalized_eigensystem.h>
26 #include <vnl/algo/vnl_symmetric_eigensystem.h>
27 #include <vnl/algo/vnl_real_eigensystem.h>
28
29 namespace clitk {
30
31   //---------------------------------------------------------------------
32   class Ellipse : public itk::Vector<double,6> {
33   public:
34     typedef itk::Vector<double,2> Vector2d;
35     typedef itk::Vector<double,6> Vector6d;
36     typedef itk::Matrix<double,6,6> Matrix6x6d;
37     typedef itk::Matrix<double,3,3> Matrix3x3d;
38
39     Ellipse();
40     Ellipse(const Ellipse & e);
41     void InitialiseEllipseFitting(double eta, unsigned int n, clitk::Signal & inputX, clitk::Signal & inputY);
42     double EllipseFittingNextIteration();
43     Vector2d ComputeCenter();
44     Vector2d ComputeSemiAxeLengths();
45     double ComputeAngleInRad();
46     void SetCenterAndSemiAxes(double x0, double y0, double r1, double r2);
47     void Copy(const Vector6d & a);
48     double GetEta() { return mEta; }
49     void UpdateSMatrix(unsigned int begin, unsigned int n, 
50                        clitk::Signal & inputX, clitk::Signal & inputY);
51
52   protected:
53     double mEta;
54     double & a;
55     double & b;
56     double & c;
57     double & d;
58     double & e;
59     double & f;
60     Matrix6x6d C;
61     Matrix6x6d Ct;
62     Matrix6x6d W;
63     Matrix6x6d Wt;
64     Matrix6x6d S;
65     Matrix6x6d Sinv;
66     Matrix6x6d St;
67     std::vector<Vector6d> z;
68     clitk::Signal * mInputX;
69     clitk::Signal * mInputY;
70
71     void CopyBlock(Matrix6x6d & out, const Matrix6x6d & in, 
72                    int ox, int oy, int l, double factor=1.0);
73     void CopyBlock(Matrix6x6d & out, const Matrix3x3d & in, 
74                    int ox, int oy, double factor=1.0);
75     Matrix3x3d GetBlock3x3(const Matrix6x6d & M, int x, int y);
76
77   };
78   //---------------------------------------------------------------------
79     
80 } // end namespace
81
82 #endif