ClosestPoint.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_ClosestPoint_H
21 #define MIRTK_ClosestPoint_H
22 
23 #include "mirtk/PointCorrespondence.h"
24 
25 #include "mirtk/Array.h"
26 
27 
28 namespace mirtk {
29 
30 
31 /**
32  * Closest point correspondence map
33  */
35 {
36  mirtkObjectMacro(ClosestPoint);
37 
38  // ---------------------------------------------------------------------------
39  // Attributes
40 protected:
41 
42  /// Mark correspondences with distance greater than the mean distance plus
43  /// _Sigma times the standard deviation of the current point distances as outliers
44  mirtkPublicAttributeMacro(double, Sigma);
45 
46  /// Mark correspondences with distance greater than this value as outliers
47  /// Unused if _Sigma is set to a non-negative value
48  mirtkPublicAttributeMacro(double, MaxDistance);
49 
50  /// Maximum squared distance
51  mirtkAttributeMacro(double, MaxSquaredDistance);
52 
53  /// Indices of target points corresponding to the respective source points
54  mirtkAttributeMacro(Array<int>, TargetIndex);
55 
56  /// Distance of closest target points from source samples
57  mirtkAttributeMacro(Array<double>, TargetDistance);
58 
59  /// Indices of source points corresponding to the respective target points
60  mirtkAttributeMacro(Array<int>, SourceIndex);
61 
62  /// Distance of closest source points from target samples
63  mirtkAttributeMacro(Array<double>, SourceDistance);
64 
65  // ---------------------------------------------------------------------------
66  // Construction/Destruction
67 public:
68 
69  /// Constructor
70  ClosestPoint();
71 
72  /// Copy constructor
73  ClosestPoint(const ClosestPoint &);
74 
75  /// Copy construct a new instance
76  virtual PointCorrespondence *NewInstance() const;
77 
78  /// Destructor
79  virtual ~ClosestPoint();
80 
81  /// Type enumeration value
82  virtual TypeId Type() const;
83 
84  // ---------------------------------------------------------------------------
85  // Parameters
86 
87  // Import other overloads
89 
90  /// Set parameter value from string
91  virtual bool Set(const char *, const char *);
92 
93  /// Get parameter key/value as string map
94  virtual ParameterList Parameter() const;
95 
96  // ---------------------------------------------------------------------------
97  // Correspondences
98 
99  /// Initialize correspondence map
100  virtual void Initialize();
101 
102  /// Update correspondence map
103  virtual void Update();
104 
105  /// Update correspondence map after convergence
106  virtual bool Upgrade();
107 
108  /// Get untransformed target point corresponding to i-th source (sample) point
109  virtual bool GetInputTargetPoint(int, Point &) const;
110 
111  /// Get untransformed source point corresponding to i-th target (sample) point
112  virtual bool GetInputSourcePoint(int, Point &) const;
113 
114  /// Get (transformed) target point corresponding to i-th source (sample) point
115  virtual bool GetTargetPoint(int, Point &) const;
116 
117  /// Get (transformed) source point corresponding to i-th target (sample) point
118  virtual bool GetSourcePoint(int, Point &) const;
119 
120  /// Get index of target point corresponding to i-th source (sample) point
121  ///
122  /// \returns Index of corresponding target point and -1 if point is an outlier
123  /// or its corresponding point is not a target vertex position.
124  virtual int GetTargetIndex(int) const;
125 
126  /// Get index of source point corresponding to i-th target (sample) point
127  ///
128  /// \returns Index of corresponding source point and -1 if point is an outlier
129  /// or its corresponding point is not a source vertex position.
130  virtual int GetSourceIndex(int) const;
131 
132 };
133 
134 
135 } // namespace mirtk
136 
137 #endif // MIRTK_ClosestPoint_H
virtual TypeId Type() const
Type enumeration value.
TypeId
Enumeration of available point correspondence maps.
virtual ~ClosestPoint()
Destructor.
virtual bool GetInputSourcePoint(int, Point &) const
Get untransformed source point corresponding to i-th target (sample) point.
virtual ParameterList Parameter() const
Get parameter key/value as string map.
virtual PointCorrespondence * NewInstance() const
Copy construct a new instance.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
Definition: Object.h:38
Definition: IOConfig.h:41
virtual int GetTargetIndex(int) const
ClosestPoint()
Constructor.
virtual bool GetInputTargetPoint(int, Point &) const
Get untransformed target point corresponding to i-th source (sample) point.
mirtkPublicAttributeMacro(double, Sigma)
virtual void Initialize()
Initialize correspondence map.
virtual bool GetSourcePoint(int, Point &) const
Get (transformed) source point corresponding to i-th target (sample) point.
virtual bool Upgrade()
Update correspondence map after convergence.
virtual void Update()
Update correspondence map.
virtual bool Set(const char *, const char *)
Set parameter value from string.
virtual int GetSourceIndex(int) const
mirtkAttributeMacro(double, MaxSquaredDistance)
Maximum squared distance.
virtual ParameterList Parameter() const
Get parameter key/value as string map.
virtual bool GetTargetPoint(int, Point &) const
Get (transformed) target point corresponding to i-th source (sample) point.