ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkVariationalRegistrationStopCriterion.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkVariationalRegistrationStopCriterion_h
19 #define __itkVariationalRegistrationStopCriterion_h
20 
21 #include "itkCommand.h"
22 #include "itkEventObject.h"
23 
26 
27 namespace itk {
28 
67 template< class TRegistrationFilter, class TMRFilter >
69  : public Command
70 {
71 public:
77 
79  typedef TRegistrationFilter RegistrationFilterType;
80  typedef TMRFilter MRFilterType;
81 
83  itkNewMacro(Self);
84 
89  itkSetMacro( IterationModulus, int );
90 
92  itkGetMacro( IterationModulus, int );
93 
95  itkSetMacro( PerformIncreaseCountCheck, bool );
96  itkGetMacro( PerformIncreaseCountCheck, bool );
97  itkBooleanMacro( PerformIncreaseCountCheck );
99 
101  itkSetMacro( MaximumIncreaseCount, int );
102 
104  itkGetMacro( MaximumIncreaseCount, int );
105 
107  itkSetMacro( PerformLineFittingCheck, bool );
108  itkGetMacro( PerformLineFittingCheck, bool );
109  itkBooleanMacro( PerformLineFittingCheck );
111 
115  itkSetMacro( PerformLineFittingMaxDistanceCheck, bool );
116  itkGetMacro( PerformLineFittingMaxDistanceCheck, bool );
117  itkBooleanMacro( PerformLineFittingMaxDistanceCheck );
119 
123  itkSetMacro( LineFittingUseAbsoluteValues, bool );
124  itkGetMacro( LineFittingUseAbsoluteValues, bool );
125  itkBooleanMacro( LineFittingUseAbsoluteValues );
127 
135  virtual void SetNumberOfFittingIterations( const int it );
136 
138  itkGetMacro( NumberOfFittingIterations, int );
139 
141  itkSetMacro( RegressionLineSlopeThreshold, double );
142 
144  itkGetMacro( RegressionLineSlopeThreshold, double );
145 
147  itkSetMacro( MaxDistanceToRegressionLine, double );
148 
150  itkGetMacro( MaxDistanceToRegressionLine, double );
151 
154  LINE_FITTING_MODE_ORIGINAL = 0,
155  LINE_FITTING_MODE_NORMALIZED = 1,
156  LINE_FITTING_MODE_SCALED = 2
157  };
158 
164  itkSetEnumMacro( LineFittingMode, LineFittingMode );
165 
167  itkGetEnumMacro( LineFittingMode, LineFittingMode );
168 
171  { this->SetLineFittingMode( LINE_FITTING_MODE_ORIGINAL ); }
172 
175  { this->SetLineFittingMode( LINE_FITTING_MODE_NORMALIZED ); }
176 
179  { this->SetLineFittingMode( LINE_FITTING_MODE_SCALED ); }
180 
183  MULTI_RESOLUTION_POLICY_DEFAULT = 0,
184  MULTI_RESOLUTION_POLICY_SIMPLE_GRADUATED = 1,
185  MULTI_RESOLUTION_POLICY_GRADUATED = 2
186  };
187 
196  itkSetEnumMacro( MultiResolutionPolicy, MultiResolutionPolicy );
197 
199  itkGetEnumMacro( MultiResolutionPolicy, MultiResolutionPolicy );
200 
203  { this->SetMultiResolutionPolicy( MULTI_RESOLUTION_POLICY_DEFAULT ); }
204 
209  { this->SetMultiResolutionPolicy( MULTI_RESOLUTION_POLICY_SIMPLE_GRADUATED ); }
210 
217  { this->SetMultiResolutionPolicy( MULTI_RESOLUTION_POLICY_GRADUATED ); }
218 
219  virtual void Execute( itk::Object *caller, const itk::EventObject & event );
220 
221  virtual void Execute( const itk::Object *caller, const itk::EventObject & event );
222 
223 protected:
226 
228  virtual void PrintSelf(std::ostream& os, Indent indent) const;
229 
232  virtual void SetModeForNextLevel(
233  const unsigned int nextLevel, const unsigned int numberOfLevels );
234 
237  virtual void SetNextMetricValue( const double value );
238 
240  virtual void ResetFittingData();
241 
244  virtual bool CheckStopRegistration();
245 
247  virtual void FitLine( const double *const x, const double *const y,
248  const int n, double *m, double *b);
249 
250 private:
251  VariationalRegistrationStopCriterion(const Self&); //purposely not implemented
252  void operator=(const Self&); //purposely not implemented
253 
254  // Stop criterion multi-resolution policy.
256 
257  // General parameter.
258  int m_IterationModulus; // Only check every mod iterations.
259  int m_ElapsedIterations; // The number of elapsed iterations.
260 
261  // Member for increase count calculation.
262  bool m_PerformIncreaseCountCheck; // Perform increase count check?
263 
266 
267  double m_MaxMetricValue; // Stores max metric value.
268  double m_MinMetricValue; // Stores min metric value.
269 
270  // Member for line fitting.
273  bool m_LineFittingUseAbsoluteValues; // Use absolute values for line fitting.
274 
275  LineFittingMode m_LineFittingMode; // Mode for the line fitting.
276 
280 
281  // Distance and iteration array.
285 };
286 
287 } // end namespace itk
288 
289 #ifndef ITK_MANUAL_INSTANTIATION
290 #include "itkVariationalRegistrationStopCriterion.hxx"
291 #endif
292 
293 #endif
Abstraction of the Events used to communicating among filters and with GUIs.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:57
Superclass for callback/observer methods.
Definition: itkCommand.h:44
A flexible stop criterion for the variational registration framework.