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: 2008-12-21 19:13:12 $
00007   Version:   $Revision: 1.11 $
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   typedef Statistics::Histogram<THistogramMeasurement, 1> HistogramType;
00100   typedef typename HistogramType::Pointer                 HistogramPointer;
00101 
00103   void SetSourceImage( const InputImageType * source )
00104     { this->SetInput( source ); }
00105   const InputImageType * GetSourceImage(void)
00106     { return this->GetInput(); }
00108 
00110   void SetReferenceImage( const InputImageType * reference );
00111   const InputImageType * GetReferenceImage(void);
00113 
00115   itkSetMacro( NumberOfHistogramLevels, unsigned long );
00116   itkGetMacro( NumberOfHistogramLevels, unsigned long );
00118 
00120   itkSetMacro( NumberOfMatchPoints, unsigned long );
00121   itkGetMacro( NumberOfMatchPoints, unsigned long );
00123 
00129   itkSetMacro( ThresholdAtMeanIntensity, bool );
00130   itkGetMacro( ThresholdAtMeanIntensity, bool );
00131   itkBooleanMacro( ThresholdAtMeanIntensity );
00133 
00135   virtual void GenerateInputRequestedRegion();
00136 
00140   itkGetObjectMacro(SourceHistogram, HistogramType);
00141   itkGetObjectMacro(ReferenceHistogram, HistogramType);
00142   itkGetObjectMacro(OutputHistogram, HistogramType);
00144 
00145 #ifdef ITK_USE_CONCEPT_CHECKING
00146 
00147   itkConceptMacro(IntConvertibleToInputCheck,
00148     (Concept::Convertible<int, InputPixelType>));
00149   itkConceptMacro(SameDimensionCheck,
00150     (Concept::SameDimension<ImageDimension, OutputImageDimension>));
00151   itkConceptMacro(DoubleConvertibleToInputCheck,
00152     (Concept::Convertible<double, InputPixelType>));
00153   itkConceptMacro(DoubleConvertibleToOutputCheck,
00154     (Concept::Convertible<double, OutputPixelType>));
00155   itkConceptMacro(InputConvertibleToDoubleCheck,
00156     (Concept::Convertible<InputPixelType, double>));
00157   itkConceptMacro(OutputConvertibleToDoubleCheck,
00158     (Concept::Convertible<OutputPixelType, double>));
00159   itkConceptMacro(SameTypeCheck,
00160     (Concept::SameType<InputPixelType, OutputPixelType>));
00161 
00163 #endif
00164 
00165 protected:
00166   HistogramMatchingImageFilter();
00167   ~HistogramMatchingImageFilter() {};
00168   void PrintSelf(std::ostream& os, Indent indent) const;
00169 
00170   void BeforeThreadedGenerateData();
00171   void AfterThreadedGenerateData();
00172   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00173                             int threadId );
00174 
00176   void ComputeMinMaxMean( const InputImageType * image,
00177                           THistogramMeasurement& minValue, THistogramMeasurement& maxValue, THistogramMeasurement& meanValue );
00178 
00180   void ConstructHistogram( const InputImageType * image,
00181                            HistogramType * histogram, const THistogramMeasurement minValue,
00182                            const THistogramMeasurement maxValue );
00183 
00184 private:
00185   HistogramMatchingImageFilter(const Self&); //purposely not implemented
00186   void operator=(const Self&); //purposely not implemented
00187 
00188   unsigned long         m_NumberOfHistogramLevels;
00189   unsigned long         m_NumberOfMatchPoints;
00190   bool                  m_ThresholdAtMeanIntensity;
00191 
00192   InputPixelType        m_SourceIntensityThreshold;
00193   InputPixelType        m_ReferenceIntensityThreshold;
00194   OutputPixelType       m_OutputIntensityThreshold;
00195 
00196   THistogramMeasurement m_SourceMinValue;
00197   THistogramMeasurement m_SourceMaxValue;
00198   THistogramMeasurement m_SourceMeanValue;
00199   THistogramMeasurement m_ReferenceMinValue;
00200   THistogramMeasurement m_ReferenceMaxValue;
00201   THistogramMeasurement m_ReferenceMeanValue;
00202   THistogramMeasurement m_OutputMinValue;
00203   THistogramMeasurement m_OutputMaxValue;
00204   THistogramMeasurement m_OutputMeanValue;
00205 
00206   HistogramPointer      m_SourceHistogram;
00207   HistogramPointer      m_ReferenceHistogram;
00208   HistogramPointer      m_OutputHistogram;
00209 
00210   typedef vnl_matrix<double>  TableType;
00211   TableType             m_QuantileTable;
00212 
00213   typedef vnl_vector<double>  GradientArrayType;
00214   GradientArrayType     m_Gradients;
00215   double                m_LowerGradient;
00216   double                m_UpperGradient;
00217 
00218 };
00219 
00220   
00221 } // end namespace itk
00222   
00223 #ifndef ITK_MANUAL_INSTANTIATION
00224 #include "itkHistogramMatchingImageFilter.txx"
00225 #endif
00226   
00227 #endif
00228 

Generated at Sat Feb 28 12:35:56 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000