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 itkStaticConstMacro(OutputImageDimension, unsigned int,
00080 TOutputImage::ImageDimension);
00082
00084 typedef typename TOutputImage::RegionType OutputImageRegionType;
00085
00087 typedef typename Superclass::InputImageType InputImageType;
00088 typedef typename Superclass::InputImagePointer InputImagePointer;
00089 typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
00090 typedef typename Superclass::OutputImageType OutputImageType;
00091 typedef typename Superclass::OutputImagePointer OutputImagePointer;
00092
00094 typedef typename InputImageType::PixelType InputPixelType;
00095 typedef typename OutputImageType::PixelType OutputPixelType;
00096
00098 typedef Statistics::Histogram<InputPixelType, 1> HistogramType;
00099 typedef typename HistogramType::Pointer HistogramPointer;
00100
00102 void SetSourceImage( const InputImageType * source )
00103 { this->SetInput( source ); }
00104 const InputImageType * GetSourceImage(void)
00105 { return this->GetInput(); }
00107
00109 void SetReferenceImage( const InputImageType * reference );
00110 const InputImageType * GetReferenceImage(void);
00112
00114 itkSetMacro( NumberOfHistogramLevels, unsigned long );
00115 itkGetMacro( NumberOfHistogramLevels, unsigned long );
00117
00119 itkSetMacro( NumberOfMatchPoints, unsigned long );
00120 itkGetMacro( NumberOfMatchPoints, unsigned long );
00122
00128 itkSetMacro( ThresholdAtMeanIntensity, bool );
00129 itkGetMacro( ThresholdAtMeanIntensity, bool );
00130 itkBooleanMacro( ThresholdAtMeanIntensity );
00132
00134 virtual void GenerateInputRequestedRegion();
00135
00139 itkGetObjectMacro(SourceHistogram, HistogramType);
00140 itkGetObjectMacro(ReferenceHistogram, HistogramType);
00141 itkGetObjectMacro(OutputHistogram, HistogramType);
00143
00144 #ifdef ITK_USE_CONCEPT_CHECKING
00145
00146 itkConceptMacro(IntConvertibleToInputCheck,
00147 (Concept::Convertible<int, InputPixelType>));
00148 itkConceptMacro(SameDimensionCheck,
00149 (Concept::SameDimension<ImageDimension, OutputImageDimension>));
00150 itkConceptMacro(DoubleConvertibleToInputCheck,
00151 (Concept::Convertible<double, InputPixelType>));
00152 itkConceptMacro(DoubleConvertibleToOutputCheck,
00153 (Concept::Convertible<double, OutputPixelType>));
00154 itkConceptMacro(InputConvertibleToDoubleCheck,
00155 (Concept::Convertible<InputPixelType, double>));
00156 itkConceptMacro(OutputConvertibleToDoubleCheck,
00157 (Concept::Convertible<OutputPixelType, double>));
00158 itkConceptMacro(SameTypeCheck,
00159 (Concept::SameType<InputPixelType, OutputPixelType>));
00160
00162 #endif
00163
00164 protected:
00165 HistogramMatchingImageFilter();
00166 ~HistogramMatchingImageFilter() {};
00167 void PrintSelf(std::ostream& os, Indent indent) const;
00168
00169 void BeforeThreadedGenerateData();
00170 void AfterThreadedGenerateData();
00171 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00172 int threadId );
00173
00175 void ComputeMinMaxMean( const InputImageType * image,
00176 double& minValue, double& maxValue, double& meanValue );
00177
00179 void ConstructHistogram( const InputImageType * image,
00180 HistogramType * histogram, double minValue,
00181 double maxValue );
00182
00183 private:
00184 HistogramMatchingImageFilter(const Self&);
00185 void operator=(const Self&);
00186
00187 unsigned long m_NumberOfHistogramLevels;
00188 unsigned long m_NumberOfMatchPoints;
00189 bool m_ThresholdAtMeanIntensity;
00190
00191 InputPixelType m_SourceIntensityThreshold;
00192 InputPixelType m_ReferenceIntensityThreshold;
00193 OutputPixelType m_OutputIntensityThreshold;
00194
00195 double m_SourceMinValue;
00196 double m_SourceMaxValue;
00197 double m_SourceMeanValue;
00198 double m_ReferenceMinValue;
00199 double m_ReferenceMaxValue;
00200 double m_ReferenceMeanValue;
00201 double m_OutputMinValue;
00202 double m_OutputMaxValue;
00203 double m_OutputMeanValue;
00204
00205 HistogramPointer m_SourceHistogram;
00206 HistogramPointer m_ReferenceHistogram;
00207 HistogramPointer m_OutputHistogram;
00208
00209 typedef vnl_matrix<double> TableType;
00210 TableType m_QuantileTable;
00211
00212 typedef vnl_vector<double> GradientArrayType;
00213 GradientArrayType m_Gradients;
00214 double m_LowerGradient;
00215 double m_UpperGradient;
00216
00217 };
00218
00219
00220 }
00221
00222 #ifndef ITK_MANUAL_INSTANTIATION
00223 #include "itkHistogramMatchingImageFilter.txx"
00224 #endif
00225
00226 #endif
00227