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: 2006/03/23 15:26:09 $
00007   Version:   $Revision: 1.8 $
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 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&); //purposely not implemented
00185   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00221   
00222 #ifndef ITK_MANUAL_INSTANTIATION
00223 #include "itkHistogramMatchingImageFilter.txx"
00224 #endif
00225   
00226 #endif
00227 

Generated at Mon Mar 12 00:42:42 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000