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
00080 typedef SmartPointer<Self> Pointer;
00081 typedef SmartPointer<const Self> ConstPointer;
00082
00084 itkNewMacro(Self);
00085
00087 itkTypeMacro(MatchCardinalityImageToImageMetric, ImageToImageMetric);
00088
00089
00091 typedef typename Superclass::RealType RealType;
00092 typedef typename Superclass::TransformType TransformType;
00093 typedef typename Superclass::TransformPointer TransformPointer;
00094 typedef typename Superclass::TransformParametersType TransformParametersType;
00095 typedef typename Superclass::TransformJacobianType TransformJacobianType;
00096 typedef typename Superclass::GradientPixelType GradientPixelType;
00097 typedef typename Superclass::InputPointType InputPointType;
00098 typedef typename Superclass::OutputPointType OutputPointType;
00099
00100 typedef typename Superclass::MeasureType MeasureType;
00101 typedef typename Superclass::DerivativeType DerivativeType;
00102 typedef typename Superclass::FixedImageType FixedImageType;
00103 typedef typename Superclass::MovingImageType MovingImageType;
00104 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
00105 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
00106 typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
00107
00108
00110 void GetDerivative( const TransformParametersType &,
00111 DerivativeType & derivative ) const
00112 {
00113 itkWarningMacro(<< "This metric does not provide metric derivatives.");
00114 derivative.Fill( NumericTraits<ITK_TYPENAME DerivativeType::ValueType>::Zero );
00115 }
00117
00124 MeasureType GetValue( const TransformParametersType & parameters ) const;
00125
00132 itkSetMacro(MeasureMatches, bool);
00133 itkBooleanMacro(MeasureMatches);
00134 itkGetMacro(MeasureMatches, bool);
00136
00138 itkSetClampMacro( NumberOfThreads, int, 1, ITK_MAX_THREADS );
00139 itkGetConstReferenceMacro( NumberOfThreads, int );
00141
00143 MultiThreader * GetMultiThreader()
00144 {return m_Threader;}
00145
00146 protected:
00147 MatchCardinalityImageToImageMetric();
00148 virtual ~MatchCardinalityImageToImageMetric() {};
00149 void PrintSelf(std::ostream& os, Indent indent) const;
00150
00156 MeasureType GetNonconstValue( const TransformParametersType & parameters );
00157
00162 virtual
00163 void ThreadedGetValue(const FixedImageRegionType& outputRegionForThread,
00164 int threadId );
00165
00171 virtual
00172 int SplitFixedRegion(int i,int num, FixedImageRegionType& splitRegion);
00173
00177 static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg );
00178
00180 struct ThreadStruct
00181 {
00182 Pointer Metric;
00183 };
00184
00185 private:
00186 MatchCardinalityImageToImageMetric(const Self&);
00187 void operator=(const Self&);
00188
00189 bool m_MeasureMatches;
00190 std::vector<MeasureType> m_ThreadMatches;
00191 std::vector<unsigned long> m_ThreadCounts;
00192
00195 MultiThreader::Pointer m_Threader;
00196 int m_NumberOfThreads;
00197 };
00198
00199
00200 }
00201
00202 #ifndef ITK_MANUAL_INSTANTIATION
00203 #include "itkMatchCardinalityImageToImageMetric.txx"
00204 #endif
00205
00206 #endif
00207
00208 #endif
00209
00210