Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkHistogramMatchingImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkHistogramMatchingImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-02 05:43:54 $
00007   Version:   $Revision: 1.13 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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   /* THistogramMeasurement -- The precision level for which to do HistogramMeasurmenets */
00060 template <class TInputImage, class TOutputImage, class THistogramMeasurement=ITK_TYPENAME TInputImage::PixelType>
00061 class ITK_EXPORT HistogramMatchingImageFilter:
00062     public ImageToImageFilter<TInputImage,TOutputImage>
00063 {
00064 public:
00066   typedef HistogramMatchingImageFilter                  Self;
00067   typedef ImageToImageFilter<TInputImage,TOutputImage>  Superclass;
00068   typedef SmartPointer<Self>                            Pointer;
00069   typedef SmartPointer<const Self>                      ConstPointer;
00070 
00072   itkNewMacro(Self);  
00073 
00075   itkTypeMacro(HistogramMatchingImageFilter, ImageToImageFilter);
00076 
00078   itkStaticConstMacro(ImageDimension, unsigned int,
00079                       TInputImage::ImageDimension);
00080   itkStaticConstMacro(OutputImageDimension, unsigned int,
00081                       TOutputImage::ImageDimension);
00083 
00085   typedef typename TOutputImage::RegionType OutputImageRegionType;
00086 
00088   typedef typename Superclass::InputImageType         InputImageType;
00089   typedef typename Superclass::InputImagePointer      InputImagePointer;
00090   typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
00091   typedef typename Superclass::OutputImageType        OutputImageType;
00092   typedef typename Superclass::OutputImagePointer     OutputImagePointer;
00093 
00095   typedef typename InputImageType::PixelType  InputPixelType;
00096   typedef typename OutputImageType::PixelType OutputPixelType;
00097 
00099 #ifdef ITK_USE_REVIEW_STATISTICS
00100   typedef Statistics::Histogram<THistogramMeasurement >   HistogramType;
00101 #else
00102   typedef Statistics::Histogram<THistogramMeasurement, 1> HistogramType;
00103 #endif
00104   typedef typename HistogramType::Pointer                 HistogramPointer;
00105 
00107   void SetSourceImage( const InputImageType * source )
00108     { this->SetInput( source ); }
00109   const InputImageType * GetSourceImage(void)
00110     { return this->GetInput(); }
00112 
00114   void SetReferenceImage( const InputImageType * reference );
00115   const InputImageType * GetReferenceImage(void);
00117 
00119   itkSetMacro( NumberOfHistogramLevels, unsigned long );
00120   itkGetConstMacro( NumberOfHistogramLevels, unsigned long );
00122 
00124   itkSetMacro( NumberOfMatchPoints, unsigned long );
00125   itkGetConstMacro( NumberOfMatchPoints, unsigned long );
00127 
00133   itkSetMacro( ThresholdAtMeanIntensity, bool );
00134   itkGetConstMacro( ThresholdAtMeanIntensity, bool );
00135   itkBooleanMacro( ThresholdAtMeanIntensity );
00137 
00139   virtual void GenerateInputRequestedRegion();
00140 
00144   itkGetObjectMacro(SourceHistogram, HistogramType);
00145   itkGetObjectMacro(ReferenceHistogram, HistogramType);
00146   itkGetObjectMacro(OutputHistogram, HistogramType);
00148 
00149 #ifdef ITK_USE_CONCEPT_CHECKING
00150 
00151   itkConceptMacro(IntConvertibleToInputCheck,
00152     (Concept::Convertible<int, InputPixelType>));
00153   itkConceptMacro(SameDimensionCheck,
00154     (Concept::SameDimension<ImageDimension, OutputImageDimension>));
00155   itkConceptMacro(DoubleConvertibleToInputCheck,
00156     (Concept::Convertible<double, InputPixelType>));
00157   itkConceptMacro(DoubleConvertibleToOutputCheck,
00158     (Concept::Convertible<double, OutputPixelType>));
00159   itkConceptMacro(InputConvertibleToDoubleCheck,
00160     (Concept::Convertible<InputPixelType, double>));
00161   itkConceptMacro(OutputConvertibleToDoubleCheck,
00162     (Concept::Convertible<OutputPixelType, double>));
00163   itkConceptMacro(SameTypeCheck,
00164     (Concept::SameType<InputPixelType, OutputPixelType>));
00165 
00167 #endif
00168 
00169 protected:
00170   HistogramMatchingImageFilter();
00171   ~HistogramMatchingImageFilter() {};
00172   void PrintSelf(std::ostream& os, Indent indent) const;
00173 
00174   void BeforeThreadedGenerateData();
00175   void AfterThreadedGenerateData();
00176   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00177                             int threadId );
00178 
00180   void ComputeMinMaxMean( const InputImageType * image,
00181                           THistogramMeasurement& minValue, THistogramMeasurement& maxValue, THistogramMeasurement& meanValue );
00182 
00184   void ConstructHistogram( const InputImageType * image,
00185                            HistogramType * histogram, const THistogramMeasurement minValue,
00186                            const THistogramMeasurement maxValue );
00187 
00188 private:
00189   HistogramMatchingImageFilter(const Self&); //purposely not implemented
00190   void operator=(const Self&); //purposely not implemented
00191 
00192   unsigned long         m_NumberOfHistogramLevels;
00193   unsigned long         m_NumberOfMatchPoints;
00194   bool                  m_ThresholdAtMeanIntensity;
00195 
00196   InputPixelType        m_SourceIntensityThreshold;
00197   InputPixelType        m_ReferenceIntensityThreshold;
00198   OutputPixelType       m_OutputIntensityThreshold;
00199 
00200   THistogramMeasurement m_SourceMinValue;
00201   THistogramMeasurement m_SourceMaxValue;
00202   THistogramMeasurement m_SourceMeanValue;
00203   THistogramMeasurement m_ReferenceMinValue;
00204   THistogramMeasurement m_ReferenceMaxValue;
00205   THistogramMeasurement m_ReferenceMeanValue;
00206   THistogramMeasurement m_OutputMinValue;
00207   THistogramMeasurement m_OutputMaxValue;
00208   THistogramMeasurement m_OutputMeanValue;
00209 
00210   HistogramPointer      m_SourceHistogram;
00211   HistogramPointer      m_ReferenceHistogram;
00212   HistogramPointer      m_OutputHistogram;
00213 
00214   typedef vnl_matrix<double>  TableType;
00215   TableType             m_QuantileTable;
00216 
00217   typedef vnl_vector<double>  GradientArrayType;
00218   GradientArrayType     m_Gradients;
00219   double                m_LowerGradient;
00220   double                m_UpperGradient;
00221 
00222 };
00223 
00224   
00225 } // end namespace itk
00226   
00227 #ifndef ITK_MANUAL_INSTANTIATION
00228 #include "itkHistogramMatchingImageFilter.txx"
00229 #endif
00230   
00231 #endif
00232 

Generated at Mon Jul 12 2010 18:32:25 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000