ITK  4.3.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 {
69 template<class TFixedPointSet, class TMovingPointSet>
71 : public ObjectToObjectMetric<TFixedPointSet::PointDimension, TMovingPointSet::PointDimension>
72 {
73 public:
74 
80 
83 
85  typedef typename Superclass::MeasureType MeasureType;
86 
88  typedef typename Superclass::ParametersType ParametersType;
89  typedef typename Superclass::ParametersValueType ParametersValueType;
90  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
91 
93  typedef typename Superclass::DerivativeType DerivativeType;
94 
96  typedef typename Superclass::FixedTransformType FixedTransformType;
97  typedef typename Superclass::FixedTransformPointer FixedTransformPointer;
98  typedef typename Superclass::FixedInputPointType FixedInputPointType;
99  typedef typename Superclass::FixedOutputPointType FixedOutputPointType;
100  typedef typename Superclass::FixedTransformParametersType FixedTransformParametersType;
101 
102  typedef typename Superclass::MovingTransformType MovingTransformType;
103  typedef typename Superclass::MovingTransformPointer MovingTransformPointer;
104  typedef typename Superclass::MovingInputPointType MovingInputPointType;
105  typedef typename Superclass::MovingOutputPointType MovingOutputPointType;
106  typedef typename Superclass::MovingTransformParametersType MovingTransformParametersType;
107 
108  typedef typename Superclass::JacobianType JacobianType;
109  typedef typename Superclass::FixedTransformJacobianType FixedTransformJacobianType;
110  typedef typename Superclass::MovingTransformJacobianType MovingTransformJacobianType;
111 
112  typedef typename Superclass::MovingDisplacementFieldTransformType DisplacementFieldTransformType;
113 
114 
116  typedef typename Superclass::DimensionType DimensionType;
117 
119  typedef TFixedPointSet FixedPointSetType;
120  typedef typename TFixedPointSet::PointType FixedPointType;
121  typedef typename TFixedPointSet::PixelType FixedPixelType;
122  typedef typename TFixedPointSet::PointsContainer FixedPointsContainer;
123 
124  itkStaticConstMacro( FixedPointDimension, DimensionType, Superclass::FixedDimension );
125 
127  typedef TMovingPointSet MovingPointSetType;
128  typedef typename TMovingPointSet::PointType MovingPointType;
129  typedef typename TMovingPointSet::PixelType MovingPixelType;
130  typedef typename TMovingPointSet::PointsContainer MovingPointsContainer;
131 
132  itkStaticConstMacro( MovingPointDimension, DimensionType, Superclass::MovingDimension );
133 
140  itkStaticConstMacro( PointDimension, DimensionType, Superclass::FixedDimension );
141 
144  typedef typename PointType::CoordRepType CoordRepType;
146  typedef typename PointsContainer::ConstIterator PointsConstIterator;
147  typedef typename PointsContainer::ElementIdentifier PointIdentifier;
148 
152 
155 
156  typedef typename DerivativeType::ValueType DerivativeValueType;
158 
160  typedef typename Superclass::VirtualImageType VirtualImageType;
161  typedef typename Superclass::VirtualImagePointer VirtualImagePointer;
162  typedef typename Superclass::VirtualPixelType VirtualPixelType;
163  typedef typename Superclass::VirtualRegionType VirtualRegionType;
164  typedef typename Superclass::VirtualSizeType VirtualSizeType;
165  typedef typename Superclass::VirtualSpacingType VirtualSpacingType;
166  typedef typename Superclass::VirtualPointType VirtualOriginType;
167  typedef typename Superclass::VirtualPointType VirtualPointType;
168  typedef typename Superclass::VirtualDirectionType VirtualDirectionType;
169  typedef typename Superclass::VirtualSizeType VirtualRadiusType;
170  typedef typename Superclass::VirtualIndexType VirtualIndexType;
171  typedef typename Superclass::VirtualPointSetType VirtualPointSetType;
172  typedef typename Superclass::VirtualPointSetPointer VirtualPointSetPointer;
173 
175  itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
176 
178  itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
179 
181  itkGetConstObjectMacro( FixedTransformedPointSet, FixedTransformedPointSetType );
182 
184  itkSetObjectMacro( MovingPointSet, MovingPointSetType );
185 
187  itkGetConstObjectMacro( MovingPointSet, MovingPointSetType );
188 
190  itkGetConstObjectMacro( MovingTransformedPointSet, MovingTransformedPointSetType );
191 
195  SizeValueType GetNumberOfComponents() const;
196 
207  virtual MeasureType GetValue() const;
208 
219  virtual void GetDerivative( DerivativeType & ) const;
220 
231  virtual void GetValueAndDerivative( MeasureType &, DerivativeType & ) const;
232 
238  virtual MeasureType GetLocalNeighborhoodValue( const PointType &, const PixelType & pixel = 0 ) const = 0;
239 
244  virtual LocalDerivativeType GetLocalNeighborhoodDerivative( const PointType &, const PixelType & pixel = 0 ) const;
245 
250  virtual void GetLocalNeighborhoodValueAndDerivative( const PointType &,
251  MeasureType &, LocalDerivativeType &, const PixelType & pixel = 0 ) const = 0;
252 
257  const VirtualPointSetType * GetVirtualTransformedPointSet();
258 
263  virtual void Initialize( void ) throw ( ExceptionObject );
264 
265  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const
266  {
267  /* An arbitrary point in the virtual domain will not always
268  * correspond to a point within either point set. */
269  return false;
270  }
271 
272 protected:
274  virtual ~PointSetToPointSetMetricv4();
275  void PrintSelf( std::ostream & os, Indent indent ) const;
276 
277  typename FixedPointSetType::ConstPointer m_FixedPointSet;
279 
281 
282  typename MovingPointSetType::ConstPointer m_MovingPointSet;
284 
286 
289 
295 
298  virtual void InitializePointSets( void ) const;
299 
304  virtual void InitializeForIteration( void ) const;
305 
311  virtual SizeValueType CalculateNumberOfValidFixedPoints( void ) const;
312 
315  void CalculateValueAndDerivative( MeasureType & value, DerivativeType & derivative, bool calculateValue ) const;
316 
323  void TransformFixedAndCreateVirtualPointSet() const;
324 
331  void TransformMovingPointSet() const;
332 
337  void InitializePointsLocators() const;
338 
343  void StorePointDerivative( const VirtualPointType &, const DerivativeType &, DerivativeType & ) const;
344 
345 private:
346  PointSetToPointSetMetricv4( const Self & ); //purposely not implemented
347  void operator=( const Self & ); //purposely not implemented
348 
351 
352  // Flag to keep track of whether a warning has already been issued
353  // regarding the number of valid points.
355 
358 };
359 } // end namespace itk
360 
361 #ifndef ITK_MANUAL_INSTANTIATION
362 #include "itkPointSetToPointSetMetricv4.hxx"
363 #endif
364 
365 #endif
366