iRoCS Toolbox  1.1.0
RootCoordinateTransform.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2015 Kun Liu, Thorsten Falk
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 #ifndef ROOTCOORDINATETRANSFORM_HH
24 #define ROOTCOORDINATETRANSFORM_HH
25 
26 #ifdef HAVE_CONFIG_H
27 #include <config.hh>
28 #endif
29 
30 #include <vector>
31 #include <blitz/array.h>
32 /*
33  * modified on Thorsten's code
34  */
35 #include <opencv2/core/core.hpp>
36 #include <opencv2/imgproc/imgproc.hpp>
37 
39 {
40 
41 public:
42 
44 
46  const blitz::TinyVector<double,3>& qcPosition,
47  const std::vector< blitz::TinyVector<double,3> >& controlPoints);
48 
50  const blitz::TinyVector<double,3>& qcPosition,const blitz::TinyVector<double,3>& pointOnAxis,
51  const std::vector< blitz::TinyVector<double,3> >& points,
52  const size_t nSegments);
53 
55 
56  void refineModel(const std::vector< blitz::TinyVector<double,3> >& points);
57 
58  blitz::TinyVector<double,3> getCoordinates(
59  const blitz::TinyVector<double,3>& pos);
60 
61  blitz::TinyVector<double,3> getCoordinatesWithNormalizedRadius(
62  const blitz::TinyVector<double,3>& pos);
63 
64  blitz::TinyVector<double, 3> getCoordinatesWithNormalizedRadius2(
65  const blitz::TinyVector<double, 3>& pos);
66 
67  const std::vector< blitz::TinyVector<double,3> >& controlPoints() const;
68 
69  void drawFittingResult(blitz::Array<char,3>& paper,blitz::TinyVector<double, 3>& elSize);
70 
71  void extractLocalAxis(const blitz::TinyVector<double,3>& origin, blitz::TinyVector<double,3>& xAxis, blitz::TinyVector<double,3>& yAxis, blitz::TinyVector<double,3>& zAxis);
72 
73  void extractLocalAxis(const blitz::TinyVector<double,3>& origin, blitz::Array<double,2>& axes);
74 
75 #if HAVE_BLITZHDF5
76 
77  void save(const std::string& fileName, const std::string& groupName) const;
78  void load(const std::string& fileName, const std::string& groupName);
79 
80 #endif
81 
82 private:
83 
84  void extrapolateControlPoints(int tail);
85  void smoothControlPoints(int tail);
86 
87 
88  blitz::TinyVector<double,3> normalizedCoordinates(
89  const blitz::TinyVector<double,3>& pos,
90  const size_t segment);
91 
92  blitz::TinyVector<double,3> denormalizedCoordinates(
93  const blitz::TinyVector<double,3>& pos,
94  const size_t segment);
95 
96  double computeDistanceToLine(
97  const blitz::TinyVector<double,3>& pos,
98  const size_t segment,
99  double& offset, double& radialDistance, double& angle);
100 
101  double computeDistanceToLineSegment(
102  const blitz::TinyVector<double,3>& pos,
103  const size_t segment,
104  double& offset, double& radialDistance, double& angle);
105 
106  void updateDerivedVariables();
107 
108  blitz::TinyVector<double,3> _qcPos;
109  std::vector< blitz::TinyVector<double,3> > _controlPoints;
110  double _qcOffset;
111  std::vector< blitz::TinyVector<double,3> > _segments;
112  std::vector<double> _segmentStartOffset;
113  std::vector< blitz::TinyVector<double,3> > _segmentDirection;
114  std::vector<double> _segmentLength;
115  std::vector< blitz::TinyVector<double,3> > _axis;
116  std::vector<double> _angle;
117  double _minX,_maxX,_step;
118  //Ellipse
119  std::vector<double> _ra;
120  std::vector<double> _rb;
121  std::vector<double> _angleToAxis;
122  std::vector<blitz::Array<double,2> > _eT;
123  std::vector<blitz::Array<double,2> > _eTinv;
124 };
125 
126 #endif
blitz::TinyVector< double, 3 > getCoordinates(const blitz::TinyVector< double, 3 > &pos)
void drawFittingResult(blitz::Array< char, 3 > &paper, blitz::TinyVector< double, 3 > &elSize)
void load(const std::string &fileName, const std::string &groupName)
void save(const std::string &fileName, const std::string &groupName) const
void extractLocalAxis(const blitz::TinyVector< double, 3 > &origin, blitz::TinyVector< double, 3 > &xAxis, blitz::TinyVector< double, 3 > &yAxis, blitz::TinyVector< double, 3 > &zAxis)
blitz::TinyVector< double, 3 > getCoordinatesWithNormalizedRadius2(const blitz::TinyVector< double, 3 > &pos)
void refineModel(const std::vector< blitz::TinyVector< double, 3 > > &points)
const std::vector< blitz::TinyVector< double, 3 > > & controlPoints() const
blitz::TinyVector< double, 3 > getCoordinatesWithNormalizedRadius(const blitz::TinyVector< double, 3 > &pos)