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 #include "itkImageToImageMetric.h"
00021 #include "itkCovariantVector.h"
00022 #include "itkPoint.h"
00023 #include "itkMultiThreader.h"
00024 #include <vector>
00025
00026 namespace itk
00027 {
00061 template < class TFixedImage, class TMovingImage >
00062 class ITK_EXPORT MatchCardinalityImageToImageMetric :
00063 public ImageToImageMetric< TFixedImage, TMovingImage>
00064 {
00065 public:
00066
00068 typedef MatchCardinalityImageToImageMetric Self;
00069 typedef ImageToImageMetric<TFixedImage, TMovingImage > Superclass;
00070
00071 typedef SmartPointer<Self> Pointer;
00072 typedef SmartPointer<const Self> ConstPointer;
00073
00075 itkNewMacro(Self);
00076
00078 itkTypeMacro(MatchCardinalityImageToImageMetric, ImageToImageMetric);
00079
00080
00082 typedef typename Superclass::RealType RealType;
00083 typedef typename Superclass::TransformType TransformType;
00084 typedef typename Superclass::TransformPointer TransformPointer;
00085 typedef typename Superclass::TransformParametersType TransformParametersType;
00086 typedef typename Superclass::TransformJacobianType TransformJacobianType;
00087 typedef typename Superclass::GradientPixelType GradientPixelType;
00088
00089 typedef typename Superclass::MeasureType MeasureType;
00090 typedef typename Superclass::DerivativeType DerivativeType;
00091 typedef typename Superclass::FixedImageType FixedImageType;
00092 typedef typename Superclass::MovingImageType MovingImageType;
00093 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
00094 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
00095 typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
00096
00097
00099 void GetDerivative( const TransformParametersType &,
00100 DerivativeType & derivative ) const
00101 {
00102 itkWarningMacro(<< "This metric does not provide metric derivatives.");
00103 derivative.Fill( NumericTraits<ITK_TYPENAME DerivativeType::ValueType>::Zero );
00104 }
00106
00113 MeasureType GetValue( const TransformParametersType & parameters ) const;
00114
00121 itkSetMacro(MeasureMatches, bool);
00122 itkBooleanMacro(MeasureMatches);
00123 itkGetMacro(MeasureMatches, bool);
00125
00127 itkSetClampMacro( NumberOfThreads, int, 1, ITK_MAX_THREADS );
00128 itkGetConstReferenceMacro( NumberOfThreads, int );
00130
00132 MultiThreader * GetMultiThreader()
00133 {return m_Threader;}
00134
00135 protected:
00136 MatchCardinalityImageToImageMetric();
00137 virtual ~MatchCardinalityImageToImageMetric() {};
00138 void PrintSelf(std::ostream& os, Indent indent) const;
00139
00145 MeasureType GetNonconstValue( const TransformParametersType & parameters );
00146
00151 virtual
00152 void ThreadedGetValue(const FixedImageRegionType& outputRegionForThread,
00153 int threadId );
00154
00160 virtual
00161 int SplitFixedRegion(int i,int num, FixedImageRegionType& splitRegion);
00162
00166 static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg );
00167
00169 struct ThreadStruct
00170 {
00171 Pointer Metric;
00172 };
00173
00174 private:
00175 MatchCardinalityImageToImageMetric(const Self&);
00176 void operator=(const Self&);
00177
00178 bool m_MeasureMatches;
00179 std::vector<MeasureType> m_ThreadMatches;
00180 std::vector<unsigned long> m_ThreadCounts;
00181
00184 MultiThreader::Pointer m_Threader;
00185 int m_NumberOfThreads;
00186 };
00187
00188 }
00189
00190 #ifndef ITK_MANUAL_INSTANTIATION
00191 #include "itkMatchCardinalityImageToImageMetric.txx"
00192 #endif
00193
00194 #endif
00195
00196
00197
00198