ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkPointSetToPointSetMetricv4.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 __itkPointSetToPointSetMetricv4_h
19 #define __itkPointSetToPointSetMetricv4_h
20 
22 
23 #include "itkFixedArray.h"
24 #include "itkPointsLocator.h"
25 #include "itkPointSet.h"
26 
27 namespace itk
28 {
63 template<class TFixedPointSet, class TMovingPointSet>
65 : public ObjectToObjectMetric<TFixedPointSet::PointDimension, TMovingPointSet::PointDimension>
66 {
67 public:
68 
74 
77 
79  typedef typename Superclass::MeasureType MeasureType;
80 
82  typedef typename Superclass::ParametersType ParametersType;
83  typedef typename Superclass::ParametersValueType ParametersValueType;
84  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
85 
87  typedef typename Superclass::DerivativeType DerivativeType;
88 
90  typedef typename Superclass::FixedTransformType FixedTransformType;
91  typedef typename Superclass::FixedTransformPointer FixedTransformPointer;
92  typedef typename Superclass::FixedInputPointType FixedInputPointType;
93  typedef typename Superclass::FixedOutputPointType FixedOutputPointType;
94  typedef typename Superclass::FixedTransformParametersType FixedTransformParametersType;
95 
96  typedef typename Superclass::MovingTransformType MovingTransformType;
97  typedef typename Superclass::MovingTransformPointer MovingTransformPointer;
98  typedef typename Superclass::MovingInputPointType MovingInputPointType;
99  typedef typename Superclass::MovingOutputPointType MovingOutputPointType;
100  typedef typename Superclass::MovingTransformParametersType MovingTransformParametersType;
101 
102  typedef typename Superclass::JacobianType JacobianType;
103  typedef typename Superclass::FixedTransformJacobianType FixedTransformJacobianType;
104  typedef typename Superclass::MovingTransformJacobianType MovingTransformJacobianType;
105 
107  typedef typename Superclass::DimensionType DimensionType;
108 
110  typedef TFixedPointSet FixedPointSetType;
111  typedef typename TFixedPointSet::PointType FixedPointType;
112  typedef typename TFixedPointSet::PixelType FixedPixelType;
113  typedef typename TFixedPointSet::PointsContainer FixedPointsContainer;
114 
115  itkStaticConstMacro( FixedPointDimension, DimensionType, Superclass::FixedDimension );
116 
118  typedef TMovingPointSet MovingPointSetType;
119  typedef typename TMovingPointSet::PointType MovingPointType;
120  typedef typename TMovingPointSet::PixelType MovingPixelType;
121  typedef typename TMovingPointSet::PointsContainer MovingPointsContainer;
122 
123  itkStaticConstMacro( MovingPointDimension, DimensionType, Superclass::MovingDimension );
124 
131  itkStaticConstMacro( PointDimension, DimensionType, Superclass::FixedDimension );
132 
134  typedef typename PointType::CoordRepType CoordRepType;
136  typedef typename PointsContainer::ConstIterator PointsConstIterator;
137  typedef typename PointsContainer::ElementIdentifier PointIdentifier;
138 
142 
145 
146  typedef typename DerivativeType::ValueType DerivativeValueType;
148 
150  typedef typename Superclass::VirtualImageType VirtualImageType;
151  typedef typename Superclass::VirtualImagePointer VirtualImagePointer;
152  typedef typename Superclass::VirtualPixelType VirtualPixelType;
153  typedef typename Superclass::VirtualRegionType VirtualRegionType;
154  typedef typename Superclass::VirtualSizeType VirtualSizeType;
155  typedef typename Superclass::VirtualSpacingType VirtualSpacingType;
156  typedef typename Superclass::VirtualPointType VirtualOriginType;
157  typedef typename Superclass::VirtualPointType VirtualPointType;
158  typedef typename Superclass::VirtualDirectionType VirtualDirectionType;
159  typedef typename Superclass::VirtualSizeType VirtualRadiusType;
160  typedef typename Superclass::VirtualIndexType VirtualIndexType;
161  typedef typename Superclass::VirtualPointSetType VirtualPointSetType;
162  typedef typename Superclass::VirtualPointSetPointer VirtualPointSetPointer;
163 
165  itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
166 
168  itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
169 
171  itkGetConstObjectMacro( FixedTransformedPointSet, FixedTransformedPointSetType );
172 
174  itkSetObjectMacro( MovingPointSet, MovingPointSetType );
175 
177  itkGetConstObjectMacro( MovingPointSet, MovingPointSetType );
178 
180  itkGetConstObjectMacro( MovingTransformedPointSet, MovingTransformedPointSetType );
181 
185  SizeValueType GetNumberOfComponents() const;
186 
197  virtual MeasureType GetValue() const;
198 
209  virtual void GetDerivative( DerivativeType & ) const;
210 
221  virtual void GetValueAndDerivative( MeasureType &, DerivativeType & ) const;
222 
227  virtual MeasureType GetLocalNeighborhoodValue( const PointType & ) const = 0;
228 
232  virtual LocalDerivativeType GetLocalNeighborhoodDerivative( const PointType & ) const;
233 
237  virtual void GetLocalNeighborhoodValueAndDerivative( const PointType &,
238  MeasureType &, LocalDerivativeType & ) const = 0;
239 
244  const VirtualPointSetType * GetVirtualTransformedPointSet();
245 
250  virtual void Initialize( void ) throw ( ExceptionObject );
251 
252  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const
253  {
254  /* An arbitrary point in the virtual domain will not always
255  * correspond to a point within either point set. */
256  return false;
257  }
258 
259 protected:
261  virtual ~PointSetToPointSetMetricv4();
262  void PrintSelf( std::ostream & os, Indent indent ) const;
263 
264  typename FixedPointSetType::ConstPointer m_FixedPointSet;
266 
268 
269  typename MovingPointSetType::ConstPointer m_MovingPointSet;
271 
273 
276 
279  virtual void InitializePointSets( void ) const;
280 
285  virtual void InitializeForIteration( void ) const;
286 
292  virtual SizeValueType CalculateNumberOfValidFixedPoints( void ) const;
293 
296  void CalculateValueAndDerivative( MeasureType & value, DerivativeType & derivative, bool calculateValue ) const;
297 
304  void TransformFixedAndCreateVirtualPointSet() const;
305 
312  void TransformMovingPointSet() const;
313 
318  void InitializePointsLocators() const;
319 
324  void StorePointDerivative( const VirtualPointType &, const DerivativeType &, DerivativeType & ) const;
325 
326 private:
327  PointSetToPointSetMetricv4( const Self & ); //purposely not implemented
328  void operator=( const Self & ); //purposely not implemented
329 
332 
333  // Flag to keep track of whether a warning has already been issued
334  // regarding the number of valid points.
336 
337  mutable unsigned long m_MovingTransformedPointSetTime;
338  mutable unsigned long m_FixedTransformedPointSetTime;
339 };
340 } // end namespace itk
341 
342 #ifndef ITK_MANUAL_INSTANTIATION
343 #include "itkPointSetToPointSetMetricv4.hxx"
344 #endif
345 
346 #endif
347