ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkPointSetToPointSetMetricv4.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkPointSetToPointSetMetricv4_h
00019 #define __itkPointSetToPointSetMetricv4_h
00020 
00021 #include "itkObjectToObjectMetric.h"
00022 
00023 #include "itkFixedArray.h"
00024 #include "itkPointsLocator.h"
00025 #include "itkPointSet.h"
00026 #include "itkTransform.h"
00027 
00028 namespace itk
00029 {
00043 template<class TFixedPointSet,  class TMovingPointSet>
00044 class ITK_EXPORT PointSetToPointSetMetricv4
00045 : public ObjectToObjectMetric
00046 {
00047 public:
00048 
00050   typedef PointSetToPointSetMetricv4 Self;
00051   typedef ObjectToObjectMetric       Superclass;
00052   typedef SmartPointer<Self>         Pointer;
00053   typedef SmartPointer<const Self>   ConstPointer;
00054 
00056   itkTypeMacro( PointSetToPointSetMetricv4, ObjectToObjectMetric );
00057 
00059   typedef TFixedPointSet                               FixedPointSetType;
00060   typedef typename TFixedPointSet::PointType           FixedPointType;
00061   typedef typename TFixedPointSet::PixelType           FixedPixelType;
00062   typedef typename TFixedPointSet::PointsContainer     FixedPointsContainer;
00063 
00064   itkStaticConstMacro( FixedPointDimension, unsigned int,
00065     TFixedPointSet::PointDimension );
00066 
00068   typedef TMovingPointSet                              MovingPointSetType;
00069   typedef typename TMovingPointSet::PointType          MovingPointType;
00070   typedef typename TMovingPointSet::PixelType          MovingPixelType;
00071   typedef typename TMovingPointSet::PointsContainer    MovingPointsContainer;
00072 
00073   itkStaticConstMacro( MovingPointDimension, unsigned int,
00074     TFixedPointSet::PointDimension );
00075 
00082   itkStaticConstMacro( PointDimension, unsigned int,
00083     TFixedPointSet::PointDimension );
00084 
00085   typedef FixedPointType                               PointType;
00086   typedef typename PointType::CoordRepType             CoordRepType;
00087   typedef FixedPointsContainer                         PointsContainer;
00088   typedef typename PointsContainer::ConstIterator      PointsConstIterator;
00089   typedef typename PointsContainer::ElementIdentifier  PointIdentifier;
00090 
00092   typedef PointsLocator<PointIdentifier,
00093     itkGetStaticConstMacro( PointDimension ),
00094     CoordRepType, PointsContainer>                     PointsLocatorType;
00095   typedef typename PointsLocatorType::
00096     NeighborsIdentifierType                            NeighborsIdentifierType;
00097 
00099   typedef Transform<CoordRepType,
00100     itkGetStaticConstMacro( FixedPointDimension ),
00101     itkGetStaticConstMacro( PointDimension )>      FixedTransformType;
00102   typedef typename FixedTransformType::Pointer     FixedTransformPointer;
00103   typedef PointSet<FixedPixelType,
00104     itkGetStaticConstMacro( PointDimension )>      FixedTransformedPointSetType;
00106 
00107   typedef Transform<CoordRepType,
00108     itkGetStaticConstMacro( MovingPointDimension ),
00109     itkGetStaticConstMacro( PointDimension )>      MovingTransformType;
00110   typedef typename MovingTransformType::Pointer    MovingTransformPointer;
00111   typedef PointSet<MovingPixelType,
00112     itkGetStaticConstMacro( PointDimension )>      MovingTransformedPointSetType;
00113 
00115   typedef typename Superclass::MeasureType MeasureType;
00116 
00118   typedef typename Superclass::ParametersType ParametersType;
00119 
00121   typedef typename Superclass::DerivativeType DerivativeType;
00122 
00123   typedef typename DerivativeType::ValueType           DerivativeValueType;
00124   typedef FixedArray<DerivativeValueType,
00125     itkGetStaticConstMacro( PointDimension )>          LocalDerivativeType;
00126 
00128   itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
00129 
00131   itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
00132 
00134   itkGetConstObjectMacro( FixedTransformedPointSet, FixedTransformedPointSetType );
00135 
00137   itkSetObjectMacro( FixedTransform, FixedTransformType );
00138 
00140   itkGetConstObjectMacro( FixedTransform, FixedTransformType );
00141 
00143   itkSetObjectMacro( MovingPointSet, MovingPointSetType );
00144 
00146   itkGetConstObjectMacro( MovingPointSet, MovingPointSetType );
00147 
00149   itkGetConstObjectMacro( MovingTransformedPointSet, MovingTransformedPointSetType );
00150 
00152   itkSetObjectMacro( MovingTransform, MovingTransformType );
00153 
00155   itkGetConstObjectMacro( MovingTransform, MovingTransformType );
00156 
00160   unsigned int GetNumberOfComponents() const;
00161 
00172   virtual MeasureType GetValue() const;
00173 
00184   virtual void GetDerivative( DerivativeType & ) const;
00185 
00196   virtual void GetValueAndDerivative( MeasureType &, DerivativeType & ) const;
00197 
00202   virtual MeasureType GetLocalNeighborhoodValue( const PointType & ) const = 0;
00203 
00207   virtual LocalDerivativeType GetLocalNeighborhoodDerivative( const PointType & ) const;
00208 
00212   virtual void GetLocalNeighborhoodValueAndDerivative( const PointType &,
00213     MeasureType &, LocalDerivativeType & ) const = 0;
00214 
00219   virtual void Initialize( void ) throw ( ExceptionObject );
00220 
00224   virtual unsigned int GetNumberOfParameters() const;
00225 
00229   virtual unsigned int GetNumberOfLocalParameters() const;
00230 
00234   virtual void SetParameters( ParametersType & );
00235 
00239   virtual const ParametersType & GetParameters() const;
00240 
00244   virtual bool HasLocalSupport() const;
00245 
00252   virtual void UpdateTransformParameters( DerivativeType & derivative, ParametersValueType factor = 1.0 );
00253 
00254 protected:
00255   PointSetToPointSetMetricv4();
00256   virtual ~PointSetToPointSetMetricv4();
00257   void PrintSelf( std::ostream & os, Indent indent ) const;
00258 
00259   typename FixedPointSetType::ConstPointer        m_FixedPointSet;
00260   typename FixedTransformedPointSetType::Pointer  m_FixedTransformedPointSet;
00261 
00262   FixedTransformPointer                           m_FixedTransform;
00263   typename PointsLocatorType::Pointer             m_FixedTransformedPointsLocator;
00264 
00265   typename MovingPointSetType::ConstPointer       m_MovingPointSet;
00266   typename MovingTransformedPointSetType::Pointer m_MovingTransformedPointSet;
00267 
00268   MovingTransformPointer                          m_MovingTransform;
00269   typename PointsLocatorType::Pointer             m_MovingTransformedPointsLocator;
00270 
00276   void TransformFixedPointSet();
00277 
00283   void TransformMovingPointSet();
00284 
00289   void InitializePointsLocators();
00290 
00291 private:
00292   PointSetToPointSetMetricv4( const Self & ); //purposely not implemented
00293   void operator=( const Self & );           //purposely not implemented
00294 };
00295 } // end namespace itk
00296 
00297 #ifndef ITK_MANUAL_INSTANTIATION
00298 #include "itkPointSetToPointSetMetricv4.hxx"
00299 #endif
00300 
00301 #endif
00302