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 }
00105
00112 MeasureType GetValue( const TransformParametersType & parameters ) const;
00113
00120 itkSetMacro(MeasureMatches, bool);
00121 itkBooleanMacro(MeasureMatches);
00122 itkGetMacro(MeasureMatches, bool);
00123
00125 itkSetClampMacro( NumberOfThreads, int, 1, ITK_MAX_THREADS );
00126 itkGetConstReferenceMacro( NumberOfThreads, int );
00127
00129 MultiThreader * GetMultiThreader()
00130 {return m_Threader;}
00131
00132 protected:
00133 MatchCardinalityImageToImageMetric();
00134 virtual ~MatchCardinalityImageToImageMetric() {};
00135 void PrintSelf(std::ostream& os, Indent indent) const;
00136
00142 MeasureType GetNonconstValue( const TransformParametersType & parameters );
00143
00148 virtual
00149 void ThreadedGetValue(const FixedImageRegionType& outputRegionForThread,
00150 int threadId );
00151
00157 virtual
00158 int SplitFixedRegion(int i,int num, FixedImageRegionType& splitRegion);
00159
00163 static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg );
00164
00166 struct ThreadStruct
00167 {
00168 Pointer Metric;
00169 };
00170
00171 private:
00172 MatchCardinalityImageToImageMetric(const Self&);
00173 void operator=(const Self&);
00174
00175 bool m_MeasureMatches;
00176 std::vector<MeasureType> m_ThreadMatches;
00177 std::vector<unsigned long> m_ThreadCounts;
00178
00181 MultiThreader::Pointer m_Threader;
00182 int m_NumberOfThreads;
00183 };
00184
00185 }
00186
00187 #ifndef ITK_MANUAL_INSTANTIATION
00188 #include "itkMatchCardinalityImageToImageMetric.txx"
00189 #endif
00190
00191 #endif
00192
00193
00194