ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkPointSetToImageMetric_h 00019 #define __itkPointSetToImageMetric_h 00020 00021 #include "itkImageBase.h" 00022 #include "itkTransform.h" 00023 #include "itkInterpolateImageFunction.h" 00024 #include "itkSingleValuedCostFunction.h" 00025 #include "itkMacro.h" 00026 #include "itkGradientRecursiveGaussianImageFilter.h" 00027 00028 namespace itk 00029 { 00047 template< class TFixedPointSet, class TMovingImage > 00048 class ITK_EXPORT PointSetToImageMetric:public SingleValuedCostFunction 00049 { 00050 public: 00052 typedef PointSetToImageMetric Self; 00053 typedef SingleValuedCostFunction Superclass; 00054 typedef SmartPointer< Self > Pointer; 00055 typedef SmartPointer< const Self > ConstPointer; 00056 00058 typedef Superclass::ParametersValueType CoordinateRepresentationType; 00059 00061 itkTypeMacro(PointSetToImageMetric, SingleValuedCostFunction); 00062 00064 typedef TMovingImage MovingImageType; 00065 typedef typename TMovingImage::PixelType MovingImagePixelType; 00066 typedef typename MovingImageType::ConstPointer MovingImageConstPointer; 00067 00069 typedef TFixedPointSet FixedPointSetType; 00070 typedef typename FixedPointSetType::ConstPointer FixedPointSetConstPointer; 00071 00073 itkStaticConstMacro(MovingImageDimension, unsigned int, 00074 TMovingImage::ImageDimension); 00075 itkStaticConstMacro(FixedPointSetDimension, unsigned int, 00076 TFixedPointSet::PointDimension); 00078 00079 typedef typename FixedPointSetType::PointsContainer::ConstIterator PointIterator; 00080 typedef typename FixedPointSetType::PointDataContainer::ConstIterator PointDataIterator; 00081 00083 typedef Transform< CoordinateRepresentationType, 00084 itkGetStaticConstMacro(MovingImageDimension), 00085 itkGetStaticConstMacro(FixedPointSetDimension) > TransformType; 00086 00087 typedef typename TransformType::Pointer TransformPointer; 00088 typedef typename TransformType::InputPointType InputPointType; 00089 typedef typename TransformType::OutputPointType OutputPointType; 00090 typedef typename TransformType::ParametersType TransformParametersType; 00091 typedef typename TransformType::JacobianType TransformJacobianType; 00092 00094 typedef InterpolateImageFunction< 00095 MovingImageType, 00096 CoordinateRepresentationType > InterpolatorType; 00097 00099 typedef typename NumericTraits< MovingImagePixelType >::RealType RealType; 00100 typedef CovariantVector< RealType, 00101 itkGetStaticConstMacro(MovingImageDimension) > GradientPixelType; 00102 typedef Image< GradientPixelType, 00103 itkGetStaticConstMacro(MovingImageDimension) > GradientImageType; 00104 typedef SmartPointer< GradientImageType > GradientImagePointer; 00105 typedef GradientRecursiveGaussianImageFilter< MovingImageType, 00106 GradientImageType > 00107 GradientImageFilterType; 00109 00110 typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer; 00111 00112 typedef typename InterpolatorType::Pointer InterpolatorPointer; 00113 00115 typedef Superclass::MeasureType MeasureType; 00116 00118 typedef Superclass::DerivativeType DerivativeType; 00119 00121 typedef Superclass::ParametersType ParametersType; 00122 00124 itkSetConstObjectMacro(FixedPointSet, FixedPointSetType); 00125 00127 itkGetConstObjectMacro(FixedPointSet, FixedPointSetType); 00128 00130 itkSetConstObjectMacro(MovingImage, MovingImageType); 00131 00133 itkGetConstObjectMacro(MovingImage, MovingImageType); 00134 00136 itkSetObjectMacro(Transform, TransformType); 00137 00139 itkGetObjectMacro(Transform, TransformType); 00140 00142 itkSetObjectMacro(Interpolator, InterpolatorType); 00143 00145 itkGetObjectMacro(Interpolator, InterpolatorType); 00146 00148 itkGetConstObjectMacro(GradientImage, GradientImageType); 00149 00151 itkGetConstReferenceMacro(NumberOfPixelsCounted, SizeValueType); 00152 00154 void SetTransformParameters(const ParametersType & parameters) const; 00155 00163 itkSetMacro(ComputeGradient, bool); 00164 itkGetConstReferenceMacro(ComputeGradient, bool); 00166 00168 unsigned int GetNumberOfParameters(void) const 00169 { return m_Transform->GetNumberOfParameters(); } 00170 00173 virtual void Initialize(void) 00174 throw ( ExceptionObject ); 00175 00176 protected: 00177 PointSetToImageMetric(); 00178 virtual ~PointSetToImageMetric() {} 00179 void PrintSelf(std::ostream & os, Indent indent) const; 00180 00181 mutable SizeValueType m_NumberOfPixelsCounted; 00182 00183 FixedPointSetConstPointer m_FixedPointSet; 00184 00185 MovingImageConstPointer m_MovingImage; 00186 00187 mutable TransformPointer m_Transform; 00188 00189 InterpolatorPointer m_Interpolator; 00190 00191 bool m_ComputeGradient; 00192 00193 GradientImagePointer m_GradientImage; 00194 private: 00195 PointSetToImageMetric(const Self &); //purposely not implemented 00196 void operator=(const Self &); //purposely not implemented 00197 }; 00198 } // end namespace itk 00199 00200 #ifndef ITK_MANUAL_INSTANTIATION 00201 #include "itkPointSetToImageMetric.hxx" 00202 #endif 00203 00204 #endif 00205