00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef _itkFEMImageMetricLoad_h_
00041 #define _itkFEMImageMetricLoad_h_
00042
00043 #include "itkFEMLoadElementBase.h"
00044
00045 #include "itkImage.h"
00046 #include "itkTranslationTransform.h"
00047
00048 #include "itkImageRegionIteratorWithIndex.h"
00049 #include "itkNeighborhoodIterator.h"
00050 #include "itkSmartNeighborhoodIterator.h"
00051 #include "itkNeighborhoodInnerProduct.h"
00052 #include "itkDerivativeOperator.h"
00053 #include "itkForwardDifferenceOperator.h"
00054 #include "itkLinearInterpolateImageFunction.h"
00055 #include "vnl/vnl_math.h"
00056
00057 #include <itkMutualInformationImageToImageMetric.h>
00058 #include <itkMeanSquaresImageToImageMetric.h>
00059 #include <itkNormalizedCorrelationImageToImageMetric.h>
00060 #include <itkPatternIntensityImageToImageMetric.h>
00061
00062
00063 namespace itk
00064 {
00065 namespace fem
00066 {
00067
00091 template<class TReference,class TTarget>
00092 class ImageMetricLoad : public LoadElement
00093 {
00094 FEM_CLASS(ImageMetricLoad,LoadElement)
00095 public:
00096
00097
00098 typedef typename LoadElement::Float Float;
00099
00100 typedef TReference ReferenceType;
00101 typedef ReferenceType* ReferencePointer;
00102 typedef TTarget TargetType;
00103 typedef TargetType* TargetPointer;
00104
00106 itkStaticConstMacro(ImageDimension, unsigned int,
00107 ReferenceType::ImageDimension);
00108
00109 typedef ImageRegionIteratorWithIndex<ReferenceType> RefRegionIteratorType;
00110 typedef ImageRegionIteratorWithIndex<TargetType> TarRegionIteratorType;
00111
00112 typedef SmartNeighborhoodIterator<ReferenceType>
00113 ReferenceNeighborhoodIteratorType;
00114 typedef typename ReferenceNeighborhoodIteratorType::IndexType
00115 ReferenceNeighborhoodIndexType;
00116 typedef typename ReferenceNeighborhoodIteratorType::RadiusType
00117 ReferenceRadiusType;
00118 typedef SmartNeighborhoodIterator<TargetType>
00119 TargetNeighborhoodIteratorType;
00120 typedef typename TargetNeighborhoodIteratorType::IndexType
00121 TargetNeighborhoodIndexType;
00122 typedef typename TargetNeighborhoodIteratorType::RadiusType
00123 TargetRadiusType;
00124
00125
00126 typedef typename ReferenceType::PixelType RefPixelType;
00127 typedef typename TargetType::PixelType TarPixelType;
00128 typedef Float PixelType;
00129 typedef Float ComputationType;
00130 typedef CovariantVector< PixelType, itkGetStaticConstMacro(ImageDimension) > CovariantVectorType;
00131 typedef Image< CovariantVectorType, itkGetStaticConstMacro(ImageDimension) > CovariantVectorImageType;
00132 typedef Image< RefPixelType, itkGetStaticConstMacro(ImageDimension) > RefImageType;
00133 typedef Image< TarPixelType, itkGetStaticConstMacro(ImageDimension) > TarImageType;
00134 typedef Image< PixelType, itkGetStaticConstMacro(ImageDimension) > ImageType;
00135 typedef vnl_vector<Float> VectorType;
00136
00137
00138
00139
00140
00141
00142 typedef double CoordinateRepresentationType;
00143 typedef Transform< CoordinateRepresentationType,itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension) > TransformBaseType;
00144 typedef TranslationTransform<CoordinateRepresentationType, itkGetStaticConstMacro(ImageDimension) > DefaultTransformType;
00145
00147 typedef ImageToImageMetric<TargetType,ReferenceType > MetricBaseType;
00148 typedef typename MetricBaseType::Pointer MetricBaseTypePointer;
00149
00150 typedef MutualInformationImageToImageMetric< ReferenceType, TargetType > MutualInformationMetricType;
00151
00152 typedef MeanSquaresImageToImageMetric< ReferenceType, TargetType > MeanSquaresMetricType;
00153
00154 typedef NormalizedCorrelationImageToImageMetric< ReferenceType, TargetType > NormalizedCorrelationMetricType;
00155
00156 typedef PatternIntensityImageToImageMetric< ReferenceType, TargetType > PatternIntensityMetricType;
00157
00158
00159
00160
00161 typedef MeanSquaresMetricType DefaultMetricType;
00162 typedef typename DefaultTransformType::ParametersType ParametersType;
00163 typedef typename DefaultTransformType::JacobianType JacobianType;
00164
00165
00166
00167
00168
00169 typedef LinearInterpolateImageFunction< ReferenceType, double > InterpolatorType;
00170
00171
00172
00173
00175 void SetMetric(MetricBaseTypePointer MP) { m_Metric=MP; };
00176
00178 void SetReferenceImage(ReferenceType* R)
00179 {
00180 m_RefImage = R;
00181 m_RefSize=m_RefImage->GetLargestPossibleRegion().GetSize();
00182 };
00183
00184 void SetMetricReferenceImage(ReferenceType* R)
00185 {
00186 m_Metric->SetMovingImage( R );
00187 m_RefSize=R->GetLargestPossibleRegion().GetSize();
00188 };
00189
00191 void SetTargetImage(TargetType* T)
00192 {
00193 m_TarImage=T;
00194 m_TarSize=T->GetLargestPossibleRegion().GetSize();
00195 };
00196 void SetMetricTargetImage(TargetType* T)
00197 {
00198 m_Metric->SetFixedImage( T ) ;
00199 m_TarSize=T->GetLargestPossibleRegion().GetSize();
00200 };
00201
00202
00203 ReferencePointer GetReferenceImage() { return m_RefImage; };
00204 TargetPointer GetTargetImage() { return m_TarImage; };
00205
00207 void SetMetricRadius(ReferenceRadiusType T) {m_MetricRadius = T; };
00209 ReferenceRadiusType GetMetricRadius() { return m_MetricRadius; };
00210
00215 void SetNumberOfIntegrationPoints(unsigned int i){ m_NumberOfIntegrationPoints=i;}
00216 unsigned int GetNumberOfIntegrationPoints(){ return m_NumberOfIntegrationPoints;}
00217
00221 void SetSign(Float s) {m_Sign=s;}
00222
00224 void SetTemp(Float s) {m_Temp=s;}
00225
00226
00228 void SetGamma(Float s) {m_Gamma=s;}
00229
00230 void SetSolution(Solution::ConstPointer ptr) { m_Solution=ptr; }
00231 Solution::ConstPointer GetSolution() { return m_Solution; }
00232
00236 Float GetMetric (VectorType InVec);
00237
00238
00239 Float GetSolution(unsigned int i,unsigned int which=0)
00240 {
00241 return m_Solution->GetSolutionValue(i,which);
00242 }
00243
00244
00245
00246
00247 void InitializeMetric(void);
00248 ImageMetricLoad();
00249 Float EvaluateMetricGivenSolution ( Element::ArrayType* el, Float step=1.0);
00250
00254 VectorType Fe1(VectorType);
00255 VectorType Fe(VectorType,VectorType);
00256
00257 static Baseclass* NewImageMetricLoad(void)
00258 { return new ImageMetricLoad; }
00259
00260
00261 protected:
00262
00263 private:
00264
00265 typename CovariantVectorImageType::Pointer m_DerivativeImage;
00266 ReferencePointer m_RefImage;
00267 TargetPointer m_TarImage;
00268 ReferenceRadiusType m_MetricRadius;
00269 typename ReferenceType::SizeType m_RefSize;
00270 typename TargetType::SizeType m_TarSize;
00271 unsigned int m_NumberOfIntegrationPoints;
00272 unsigned int m_SolutionIndex;
00273 unsigned int m_SolutionIndex2;
00274 Float m_Sign;
00275 Float m_Temp;
00276 Float m_Gamma;
00277
00278 typename Solution::ConstPointer m_Solution;
00279 MetricBaseTypePointer m_Metric;
00280 typename TransformBaseType::Pointer m_Transform;
00281 typename InterpolatorType::Pointer m_Interpolator;
00282
00283 private:
00286 static const int DummyCLID;
00287
00288 };
00289
00290
00291
00292
00293 }}
00294
00295 #ifndef ITK_MANUAL_INSTANTIATION
00296 #include "itkFEMImageMetricLoad.txx"
00297 #endif
00298
00299 #endif