itkMatchCardinalityImageToImageMetric.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkMatchCardinalityImageToImageMetric_h
00018 #define __itkMatchCardinalityImageToImageMetric_h
00019
00020
00021
00022
00023 #include "itkConfigure.h"
00024
00025 #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
00026 #include "itkOptMatchCardinalityImageToImageMetric.h"
00027 #else
00028
00029 #include "itkImageToImageMetric.h"
00030 #include "itkCovariantVector.h"
00031 #include "itkPoint.h"
00032 #include "itkMultiThreader.h"
00033 #include <vector>
00034
00035 namespace itk
00036 {
00070 template < class TFixedImage, class TMovingImage >
00071 class ITK_EXPORT MatchCardinalityImageToImageMetric :
00072 public ImageToImageMetric< TFixedImage, TMovingImage>
00073 {
00074 public:
00075
00077 typedef MatchCardinalityImageToImageMetric Self;
00078 typedef ImageToImageMetric<TFixedImage, TMovingImage > Superclass;
00079 typedef SmartPointer<Self> Pointer;
00080 typedef SmartPointer<const Self> ConstPointer;
00081
00083 itkNewMacro(Self);
00084
00086 itkTypeMacro(MatchCardinalityImageToImageMetric, ImageToImageMetric);
00087
00088
00090 typedef typename Superclass::RealType RealType;
00091 typedef typename Superclass::TransformType TransformType;
00092 typedef typename Superclass::TransformPointer TransformPointer;
00093 typedef typename Superclass::TransformParametersType TransformParametersType;
00094 typedef typename Superclass::TransformJacobianType TransformJacobianType;
00095 typedef typename Superclass::GradientPixelType GradientPixelType;
00096 typedef typename Superclass::InputPointType InputPointType;
00097 typedef typename Superclass::OutputPointType OutputPointType;
00098
00099 typedef typename Superclass::MeasureType MeasureType;
00100 typedef typename Superclass::DerivativeType DerivativeType;
00101 typedef typename Superclass::FixedImageType FixedImageType;
00102 typedef typename Superclass::MovingImageType MovingImageType;
00103 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
00104 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
00105 typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
00106
00107
00109 void GetDerivative( const TransformParametersType &,
00110 DerivativeType & derivative ) const
00111 {
00112 itkWarningMacro(<< "This metric does not provide metric derivatives.");
00113 derivative.Fill( NumericTraits<ITK_TYPENAME DerivativeType::ValueType>::Zero );
00114 }
00116
00123 MeasureType GetValue( const TransformParametersType & parameters ) const;
00124
00131 itkSetMacro(MeasureMatches, bool);
00132 itkBooleanMacro(MeasureMatches);
00133 itkGetMacro(MeasureMatches, bool);
00135
00137 itkSetClampMacro( NumberOfThreads, int, 1, ITK_MAX_THREADS );
00138 itkGetConstReferenceMacro( NumberOfThreads, int );
00140
00142 MultiThreader * GetMultiThreader()
00143 {return m_Threader;}
00144
00145 protected:
00146 MatchCardinalityImageToImageMetric();
00147 virtual ~MatchCardinalityImageToImageMetric() {};
00148 void PrintSelf(std::ostream& os, Indent indent) const;
00149
00155 MeasureType GetNonconstValue( const TransformParametersType & parameters );
00156
00161 virtual
00162 void ThreadedGetValue(const FixedImageRegionType& outputRegionForThread,
00163 int threadId );
00164
00170 virtual
00171 int SplitFixedRegion(int i,int num, FixedImageRegionType& splitRegion);
00172
00176 static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg );
00177
00179 struct ThreadStruct
00180 {
00181 Pointer Metric;
00182 };
00183
00184 private:
00185 MatchCardinalityImageToImageMetric(const Self&);
00186 void operator=(const Self&);
00187
00188 bool m_MeasureMatches;
00189 std::vector<MeasureType> m_ThreadMatches;
00190 std::vector<unsigned long> m_ThreadCounts;
00191
00194 MultiThreader::Pointer m_Threader;
00195 int m_NumberOfThreads;
00196 };
00197
00198
00199 }
00200
00201 #ifndef ITK_MANUAL_INSTANTIATION
00202 #include "itkMatchCardinalityImageToImageMetric.txx"
00203 #endif
00204
00205 #endif
00206
00207 #endif
00208