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 __itkImageToSpatialObjectMetric_h 00019 #define __itkImageToSpatialObjectMetric_h 00020 00021 #include "itkSingleValuedCostFunction.h" 00022 #include "itkMinimumMaximumImageCalculator.h" 00023 #include "itkLinearInterpolateImageFunction.h" 00024 #include "vnl/vnl_vector_fixed.h" 00025 #include "itkTransform.h" 00026 00027 namespace itk 00028 { 00060 template< class TFixedImage, class TMovingSpatialObject > 00061 class ITK_EXPORT ImageToSpatialObjectMetric: 00062 public SingleValuedCostFunction 00063 { 00064 public: 00065 typedef ImageToSpatialObjectMetric Self; 00066 typedef SingleValuedCostFunction Superclass; 00067 typedef SmartPointer< Self > Pointer; 00068 typedef SmartPointer< const Self > ConstPointer; 00069 00071 typedef TFixedImage FixedImageType; 00072 00074 typedef TMovingSpatialObject MovingSpatialObjectType; 00075 00077 typedef Superclass::ParametersValueType CoordinateRepresentationType; 00078 00080 itkStaticConstMacro(ImageDimension, unsigned int, 00081 FixedImageType::ImageDimension); 00082 00084 itkStaticConstMacro(ObjectDimension, unsigned int, 00085 MovingSpatialObjectType::ObjectDimension); 00086 00088 typedef Transform< CoordinateRepresentationType, 00089 itkGetStaticConstMacro(ObjectDimension), 00090 itkGetStaticConstMacro(ImageDimension) > TransformType; 00091 00092 typedef typename TransformType::Pointer TransformPointer; 00093 typedef typename TransformType::InputPointType InputPointType; 00094 typedef typename TransformType::OutputPointType OutputPointType; 00095 typedef typename TransformType::ParametersType TransformParametersType; 00096 typedef typename TransformType::JacobianType TransformJacobianType; 00097 00099 typedef LinearInterpolateImageFunction< 00100 TFixedImage, 00101 CoordinateRepresentationType > InterpolatorType; 00102 00103 typedef typename InterpolatorType::Pointer InterpolatorPointer; 00104 00106 typedef vnl_vector_fixed< double, 00107 itkGetStaticConstMacro(ObjectDimension) > VectorType; 00108 00110 typedef Superclass::MeasureType MeasureType; 00111 00113 typedef Superclass::DerivativeType DerivativeType; 00114 00116 typedef typename FixedImageType::Pointer FixedImagePointer; 00117 00119 typedef typename MovingSpatialObjectType::Pointer 00120 MovingSpatialObjectPointer; 00121 00123 typedef typename FixedImageType::ConstPointer FixedImageConstPointer; 00124 00126 typedef typename MovingSpatialObjectType::ConstPointer MovingSpatialObjectConstPointer; 00127 00130 typedef Superclass::ParametersType ParametersType; 00131 00133 itkTypeMacro(ImageToSpatialObjectMetric, Object); 00134 00136 itkSetConstObjectMacro(FixedImage, FixedImageType); 00137 00139 itkGetConstObjectMacro(FixedImage, FixedImageType); 00140 00142 itkSetConstObjectMacro(MovingSpatialObject, MovingSpatialObjectType); 00143 00145 itkGetConstObjectMacro(MovingSpatialObject, MovingSpatialObjectType); 00146 00148 itkSetObjectMacro(Interpolator, InterpolatorType); 00149 00151 itkGetObjectMacro(Interpolator, InterpolatorType); 00152 00154 virtual void GetValueAndDerivative(const ParametersType & parameters, 00155 MeasureType & Value, 00156 DerivativeType & Derivative) const = 0; 00157 00159 virtual void Initialize(void) 00160 throw ( ExceptionObject ); 00161 00164 itkGetConstReferenceMacro(LastTransformParameters, ParametersType); 00165 00167 itkSetObjectMacro(Transform, TransformType); 00168 protected: 00169 00170 ImageToSpatialObjectMetric(); 00171 virtual ~ImageToSpatialObjectMetric() {} 00172 ImageToSpatialObjectMetric(const Self &) {} 00173 void operator=(const Self &) {} 00174 void PrintSelf(std::ostream & os, Indent indent) const; 00175 00176 MeasureType m_MatchMeasure; 00177 DerivativeType m_MatchMeasureDerivatives; 00178 mutable TransformPointer m_Transform; 00179 InterpolatorPointer m_Interpolator; 00180 00181 MovingSpatialObjectConstPointer m_MovingSpatialObject; 00182 FixedImageConstPointer m_FixedImage; 00183 ParametersType m_LastTransformParameters; 00184 }; 00185 } // end namespace itk 00186 00187 #ifndef ITK_MANUAL_INSTANTIATION 00188 #include "itkImageToSpatialObjectMetric.hxx" 00189 #endif 00190 00191 #endif 00192