ITK  4.8.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<typename TFixedPointSet, typename TMovingPointSet,
70  class TInternalComputationValueType = double>
72 : public ObjectToObjectMetric<TFixedPointSet::PointDimension, TMovingPointSet::PointDimension,
73  Image<TInternalComputationValueType, TFixedPointSet::PointDimension>, TInternalComputationValueType>
74 {
75 public:
76 
79  typedef ObjectToObjectMetric<TFixedPointSet::PointDimension,
80  TMovingPointSet::PointDimension,
82  TInternalComputationValueType> Superclass;
85 
88 
90  typedef typename Superclass::MeasureType MeasureType;
91 
96 
99 
106 
112 
116 
118 
120 
123 
125  typedef TFixedPointSet FixedPointSetType;
126  typedef typename TFixedPointSet::PointType FixedPointType;
127  typedef typename TFixedPointSet::PixelType FixedPixelType;
128  typedef typename TFixedPointSet::PointsContainer FixedPointsContainer;
129 
131 
133  typedef TMovingPointSet MovingPointSetType;
134  typedef typename TMovingPointSet::PointType MovingPointType;
135  typedef typename TMovingPointSet::PixelType MovingPixelType;
136  typedef typename TMovingPointSet::PointsContainer MovingPointsContainer;
137 
139 
147 
150  typedef typename PointType::CoordRepType CoordRepType;
152  typedef typename PointsContainer::ConstIterator PointsConstIterator;
153  typedef typename PointsContainer::ElementIdentifier PointIdentifier;
154 
158 
161 
162  typedef typename DerivativeType::ValueType DerivativeValueType;
164 
179 
181  virtual void SetFixedObject( const ObjectType *object ) ITK_OVERRIDE
182  {
183  FixedPointSetType *pointSet = dynamic_cast<FixedPointSetType *>( const_cast<ObjectType *>( object ) );
184  if( pointSet != ITK_NULLPTR )
185  {
186  this->SetFixedPointSet( pointSet );
187  }
188  else
189  {
190  itkExceptionMacro( "Incorrect object type. Should be a point set." )
191  }
192  }
194 
196  virtual void SetMovingObject( const ObjectType *object ) ITK_OVERRIDE
197  {
198  MovingPointSetType *pointSet = dynamic_cast<MovingPointSetType *>( const_cast<ObjectType *>( object ) );
199  if( pointSet != ITK_NULLPTR )
200  {
201  this->SetMovingPointSet( pointSet );
202  }
203  else
204  {
205  itkExceptionMacro( "Incorrect object type. Should be a point set." )
206  }
207  }
209 
211  itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
212  itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
214 
216  itkGetModifiableObjectMacro( FixedTransformedPointSet, FixedTransformedPointSetType );
217 
219  itkSetConstObjectMacro( MovingPointSet, MovingPointSetType );
220  itkGetConstObjectMacro( MovingPointSet, MovingPointSetType );
222 
224  itkGetModifiableObjectMacro( MovingTransformedPointSet, MovingTransformedPointSetType );
225 
230 
241  virtual MeasureType GetValue() const ITK_OVERRIDE;
242 
253  virtual void GetDerivative( DerivativeType & ) const ITK_OVERRIDE;
254 
265  virtual void GetValueAndDerivative( MeasureType &, DerivativeType & ) const ITK_OVERRIDE;
266 
272  virtual MeasureType GetLocalNeighborhoodValue( const PointType &, const PixelType & pixel ) const = 0;
273 
278  virtual LocalDerivativeType GetLocalNeighborhoodDerivative( const PointType &, const PixelType & pixel ) const;
279 
284  virtual void GetLocalNeighborhoodValueAndDerivative( const PointType &,
285  MeasureType &, LocalDerivativeType &, const PixelType & pixel ) const = 0;
286 
292 
297  virtual void Initialize( void ) throw ( ExceptionObject ) ITK_OVERRIDE;
298 
299  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const ITK_OVERRIDE
300  {
301  /* An arbitrary point in the virtual domain will not always
302  * correspond to a point within either point set. */
303  return false;
304  }
305 
317  itkSetMacro( StoreDerivativeAsSparseFieldForLocalSupportTransforms, bool );
318  itkGetConstMacro( StoreDerivativeAsSparseFieldForLocalSupportTransforms, bool );
319  itkBooleanMacro( StoreDerivativeAsSparseFieldForLocalSupportTransforms );
321 
325  itkSetMacro( CalculateValueAndDerivativeInTangentSpace, bool );
326  itkGetConstMacro( CalculateValueAndDerivativeInTangentSpace, bool );
327  itkBooleanMacro( CalculateValueAndDerivativeInTangentSpace );
329 
330 protected:
332  virtual ~PointSetToPointSetMetricv4();
333  void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
334 
335  typename FixedPointSetType::ConstPointer m_FixedPointSet;
337 
339 
340  typename MovingPointSetType::ConstPointer m_MovingPointSet;
342 
344 
347 
353 
362 
365  virtual void InitializePointSets() const;
366 
371  virtual void InitializeForIteration() const;
372 
379 
382  void CalculateValueAndDerivative( MeasureType & value, DerivativeType & derivative, bool calculateValue ) const;
383 
391 
398  void TransformMovingPointSet() const;
399 
404  void InitializePointsLocators() const;
405 
410  void StorePointDerivative( const VirtualPointType &, const DerivativeType &, DerivativeType & ) const;
411 
413 
415  virtual MetricCategoryType GetMetricCategory() const ITK_OVERRIDE
416  {
418  }
419 
420 
421 private:
422  PointSetToPointSetMetricv4( const Self & ); //purposely not implemented
423  void operator=( const Self & ); //purposely not implemented
424 
427 
428  // Flag to keep track of whether a warning has already been issued
429  // regarding the number of valid points.
431 
432  // Flag to store derivatives at fixed point locations with the rest being zero gradient
433  // (default = true).
435 
438 };
439 } // end namespace itk
440 
441 #ifndef ITK_MANUAL_INSTANTIATION
442 #include "itkPointSetToPointSetMetricv4.hxx"
443 #endif
444 
445 #endif
Transform< TInternalComputationValueType, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >::ImageDimension, TMovingDimension > MovingTransformType
PointsContainer::ConstIterator PointsConstIterator
const VirtualPointSetType * GetVirtualTransformedPointSet() const
Superclass::VirtualImageType VirtualImageType
PointSet< FixedPixelType, itkGetStaticConstMacro(PointDimension)> FixedTransformedPointSetType
MovingPointSetType::ConstPointer m_MovingPointSet
PointsContainer::ElementIdentifier PointIdentifier
PointsLocatorType::NeighborsIdentifierType NeighborsIdentifierType
virtual void InitializeForIteration() const
FixedPointSetType::ConstPointer m_FixedPointSet
PointSet< MovingPixelType, itkGetStaticConstMacro(PointDimension)> MovingTransformedPointSetType
ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType > Superclass
Superclass::FixedTransformParametersType FixedTransformParametersType
Superclass::VirtualPointSetType VirtualPointSetType
virtual void GetValueAndDerivative(MeasureType &, DerivativeType &) const override
virtual bool SupportsArbitraryVirtualDomainSamples(void) const override
SizeValueType GetNumberOfComponents() const
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
Computes similarity between two point sets.
Transform< TInternalComputationValueType, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >::ImageDimension, TFixedDimension > FixedTransformType
Superclass::MovingInputPointType MovingInputPointType
PointsLocator< PointsContainer > PointsLocatorType
TInternalComputationValueType ParametersValueType
virtual LocalDerivativeType GetLocalNeighborhoodDerivative(const PointType &, const PixelType &pixel) const
virtual MetricCategoryType GetMetricCategory() const override
Superclass::MovingOutputPointType MovingOutputPointType
Computes similarity between regions of two objects.
virtual MeasureType GetValue() const override
Superclass::VirtualPixelType VirtualPixelType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
virtual void Initialize(void) override
Superclass::VirtualSpacingType VirtualSpacingType
TFixedPointSet::PointsContainer FixedPointsContainer
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:50
Superclass::VirtualImagePointer VirtualImagePointer
Superclass::VirtualPointType VirtualPointType
void InitializePointsLocators() const
Accelerate geometric searches for points.
PointsLocatorType::Pointer m_MovingTransformedPointsLocator
Superclass::VirtualIndexType VirtualIndexType
FixedArray< DerivativeValueType, itkGetStaticConstMacro(PointDimension)> LocalDerivativeType
void CalculateValueAndDerivative(MeasureType &value, DerivativeType &derivative, bool calculateValue) const
static const DimensionType FixedPointDimension
virtual SizeValueType CalculateNumberOfValidFixedPoints() const
Superclass::VirtualSizeType VirtualRadiusType
Superclass::FixedOutputPointType FixedOutputPointType
void PrintSelf(std::ostream &os, Indent indent) const override
static const DimensionType MovingPointDimension
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
Superclass::FixedTransformPointer FixedTransformPointer
virtual void GetDerivative(DerivativeType &) const override
Standard exception handling object.
Superclass::MovingDisplacementFieldTransformType DisplacementFieldTransformType
Superclass::FixedTransformJacobianType FixedTransformJacobianType
virtual void SetFixedPointSet(const FixedPointSetType *_arg)
virtual void InitializePointSets() const
TMovingPointSet::PointsContainer MovingPointsContainer
TreeType::InstanceIdentifierVectorType NeighborsIdentifierType
Superclass::MovingTransformType MovingTransformType
void TransformFixedAndCreateVirtualPointSet() const
Superclass::VirtualRegionType VirtualRegionType
Superclass::VirtualPointType VirtualOriginType
PointsLocatorType::Pointer m_FixedTransformedPointsLocator
virtual void GetLocalNeighborhoodValueAndDerivative(const PointType &, MeasureType &, LocalDerivativeType &, const PixelType &pixel) const =0
FixedTransformedPointSetType::Pointer m_FixedTransformedPointSet
virtual void SetMovingPointSet(const MovingPointSetType *_arg)
Superclass::MovingTransformPointer MovingTransformPointer
Superclass::MovingTransformJacobianType MovingTransformJacobianType
virtual void SetFixedObject(const ObjectType *object) override
virtual void SetMovingObject(const ObjectType *object) override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual MeasureType GetLocalNeighborhoodValue(const PointType &, const PixelType &pixel) const =0
void StorePointDerivative(const VirtualPointType &, const DerivativeType &, DerivativeType &) const
void operator=(const Self &)
MovingTransformedPointSetType::Pointer m_MovingTransformedPointSet
Superclass::MetricCategoryType MetricCategoryType
Base class for most ITK classes.
Definition: itkObject.h:57
Superclass::FixedInputPointType FixedInputPointType
Superclass::FixedTransformType FixedTransformType
Superclass::VirtualPointSetPointer VirtualPointSetPointer
Superclass::ParametersValueType ParametersValueType
Superclass::NumberOfParametersType NumberOfParametersType
Templated n-dimensional image class.
Definition: itkImage.h:75
Superclass::MovingTransformParametersType MovingTransformParametersType
Superclass::VirtualDirectionType VirtualDirectionType