00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkHistogramMatchingImageFilter_h
00018 #define __itkHistogramMatchingImageFilter_h
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkHistogram.h"
00022 #include "vnl/vnl_matrix.h"
00023
00024 namespace itk
00025 {
00026
00059 template <class TInputImage, class TOutputImage>
00060 class ITK_EXPORT HistogramMatchingImageFilter:
00061 public ImageToImageFilter<TInputImage,TOutputImage>
00062 {
00063 public:
00065 typedef HistogramMatchingImageFilter Self;
00066 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00067 typedef SmartPointer<Self> Pointer;
00068 typedef SmartPointer<const Self> ConstPointer;
00069
00071 itkNewMacro(Self);
00072
00074 itkTypeMacro(HistogramMatchingImageFilter, ImageToImageFilter);
00075
00077 itkStaticConstMacro(ImageDimension, unsigned int,
00078 TInputImage::ImageDimension);
00079
00081 typedef typename TOutputImage::RegionType OutputImageRegionType;
00082
00084 typedef typename Superclass::InputImageType InputImageType;
00085 typedef typename Superclass::InputImagePointer InputImagePointer;
00086 typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
00087 typedef typename Superclass::OutputImageType OutputImageType;
00088 typedef typename Superclass::OutputImagePointer OutputImagePointer;
00089
00091 typedef typename InputImageType::PixelType InputPixelType;
00092 typedef typename OutputImageType::PixelType OutputPixelType;
00093
00095 typedef Statistics::Histogram<InputPixelType, 1> HistogramType;
00096 typedef typename HistogramType::Pointer HistogramPointer;
00097
00099 void SetSourceImage( const InputImageType * source )
00100 { this->SetInput( source ); }
00101 const InputImageType * GetSourceImage(void)
00102 { return this->GetInput(); }
00103
00105 void SetReferenceImage( const InputImageType * reference );
00106 const InputImageType * GetReferenceImage(void);
00107
00109 itkSetMacro( NumberOfHistogramLevels, unsigned long );
00110 itkGetMacro( NumberOfHistogramLevels, unsigned long );
00111
00113 itkSetMacro( NumberOfMatchPoints, unsigned long );
00114 itkGetMacro( NumberOfMatchPoints, unsigned long );
00115
00121 itkSetMacro( ThresholdAtMeanIntensity, bool );
00122 itkGetMacro( ThresholdAtMeanIntensity, bool );
00123 itkBooleanMacro( ThresholdAtMeanIntensity );
00124
00126 virtual void GenerateInputRequestedRegion();
00127
00128 protected:
00129 HistogramMatchingImageFilter();
00130 ~HistogramMatchingImageFilter() {};
00131 void PrintSelf(std::ostream& os, Indent indent) const;
00132
00133 void BeforeThreadedGenerateData();
00134 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00135 int threadId );
00136
00138 void ComputeMinMaxMean( const InputImageType * image,
00139 double& minValue, double& maxValue, double& meanValue );
00140
00142 void ConstructHistogram( const InputImageType * image,
00143 HistogramType * histogram, double minValue,
00144 double maxValue );
00145
00146 private:
00147 HistogramMatchingImageFilter(const Self&);
00148 void operator=(const Self&);
00149
00150 unsigned long m_NumberOfHistogramLevels;
00151 unsigned long m_NumberOfMatchPoints;
00152 bool m_ThresholdAtMeanIntensity;
00153
00154 InputPixelType m_SourceIntensityThreshold;
00155 InputPixelType m_ReferenceIntensityThreshold;
00156
00157 double m_SourceMinValue;
00158 double m_SourceMaxValue;
00159 double m_SourceMeanValue;
00160 double m_ReferenceMinValue;
00161 double m_ReferenceMaxValue;
00162 double m_ReferenceMeanValue;
00163
00164 typedef vnl_matrix<double> TableType;
00165 TableType m_QuantileTable;
00166
00167 typedef vnl_vector<double> GradientArrayType;
00168 GradientArrayType m_Gradients;
00169 double m_LowerGradient;
00170 double m_UpperGradient;
00171
00172 };
00173
00174
00175 }
00176
00177 #ifndef ITK_MANUAL_INSTANTIATION
00178 #include "itkHistogramMatchingImageFilter.txx"
00179 #endif
00180
00181 #endif