ITK  4.4.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  itkGetConstObjectMacro(FixedPointSet, FixedPointSetType );
178 
180  itkGetModifiableObjectMacro(FixedTransformedPointSet, FixedTransformedPointSetType );
181 
183  itkSetConstObjectMacro( MovingPointSet, MovingPointSetType );
184 
186  itkGetModifiableObjectMacro(MovingTransformedPointSet, MovingTransformedPointSetType );
187 
191  SizeValueType GetNumberOfComponents() const;
192 
203  virtual MeasureType GetValue() const;
204 
215  virtual void GetDerivative( DerivativeType & ) const;
216 
227  virtual void GetValueAndDerivative( MeasureType &, DerivativeType & ) const;
228 
234  virtual MeasureType GetLocalNeighborhoodValue( const PointType &, const PixelType & pixel = 0 ) const = 0;
235 
240  virtual LocalDerivativeType GetLocalNeighborhoodDerivative( const PointType &, const PixelType & pixel = 0 ) const;
241 
246  virtual void GetLocalNeighborhoodValueAndDerivative( const PointType &,
247  MeasureType &, LocalDerivativeType &, const PixelType & pixel = 0 ) const = 0;
248 
253  const VirtualPointSetType * GetVirtualTransformedPointSet( void ) const;
254 
259  virtual void Initialize( void ) throw ( ExceptionObject );
260 
261  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const
262  {
263  /* An arbitrary point in the virtual domain will not always
264  * correspond to a point within either point set. */
265  return false;
266  }
267 
268 protected:
270  virtual ~PointSetToPointSetMetricv4();
271  void PrintSelf( std::ostream & os, Indent indent ) const;
272 
273  typename FixedPointSetType::ConstPointer m_FixedPointSet;
275 
277 
278  typename MovingPointSetType::ConstPointer m_MovingPointSet;
280 
282 
285 
291 
294  virtual void InitializePointSets( void ) const;
295 
300  virtual void InitializeForIteration( void ) const;
301 
307  virtual SizeValueType CalculateNumberOfValidFixedPoints( void ) const;
308 
311  void CalculateValueAndDerivative( MeasureType & value, DerivativeType & derivative, bool calculateValue ) const;
312 
319  void TransformFixedAndCreateVirtualPointSet() const;
320 
327  void TransformMovingPointSet() const;
328 
333  void InitializePointsLocators() const;
334 
339  void StorePointDerivative( const VirtualPointType &, const DerivativeType &, DerivativeType & ) const;
340 
341 private:
342  PointSetToPointSetMetricv4( const Self & ); //purposely not implemented
343  void operator=( const Self & ); //purposely not implemented
344 
347 
348  // Flag to keep track of whether a warning has already been issued
349  // regarding the number of valid points.
351 
354 };
355 } // end namespace itk
356 
357 #ifndef ITK_MANUAL_INSTANTIATION
358 #include "itkPointSetToPointSetMetricv4.hxx"
359 #endif
360 
361 #endif
362