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

itkMovingHistogramImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMovingHistogramImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/04/30 21:02:03 $
00007   Version:   $Revision: 1.15 $
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 __itkMovingHistogramImageFilter_h
00018 #define __itkMovingHistogramImageFilter_h
00019 
00020 #include "itkImageToImageFilter.h"
00021 #include <list>
00022 #include <map>
00023 #include <set>
00024 #include "itkOffsetLexicographicCompare.h"
00025 
00026 //#define zigzag
00027 
00028 namespace itk {
00029 
00045 template<class TInputImage, class TOutputImage, class TKernel, class THistogram >
00046 class ITK_EXPORT MovingHistogramImageFilter : 
00047     public ImageToImageFilter<TInputImage, TOutputImage>
00048 {
00049 public:
00051   typedef MovingHistogramImageFilter Self;
00052   typedef ImageToImageFilter<TInputImage,TOutputImage>  Superclass;
00053   typedef SmartPointer<Self>        Pointer;
00054   typedef SmartPointer<const Self>  ConstPointer;
00055 
00057   itkNewMacro(Self);  
00058 
00060   itkTypeMacro(MovingHistogramImageFilter, 
00061                ImageToImageFilter);
00062 
00064   typedef TInputImage InputImageType;
00065   typedef TOutputImage OutputImageType;
00066   typedef typename TInputImage::RegionType RegionType ;
00067   typedef typename TInputImage::SizeType SizeType ;
00068   typedef typename TInputImage::IndexType IndexType ;
00069   typedef typename TInputImage::PixelType PixelType ;
00070   typedef typename TInputImage::OffsetType OffsetType ;
00071   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00072   typedef typename TOutputImage::PixelType OutputPixelType ;
00073 
00075   itkStaticConstMacro(ImageDimension, unsigned int,
00076                       TInputImage::ImageDimension);
00077 
00079   typedef TKernel KernelType;
00080 
00082   typedef typename KernelType::ConstIterator KernelIteratorType ;
00083 
00085   typedef typename KernelType::SizeType RadiusType ;
00086 
00087   typedef typename std::list< OffsetType > OffsetListType;
00088 
00089   typedef typename std::map< OffsetType, OffsetListType, typename Functor::OffsetLexicographicCompare<ImageDimension> > OffsetMapType;
00090 
00092   void SetKernel( const KernelType& kernel );
00093 
00095   itkGetConstReferenceMacro(Kernel, KernelType);
00096 
00097   itkGetMacro(PixelsPerTranslation, unsigned long);
00098   
00104   void GenerateInputRequestedRegion() ;
00105 
00106 protected:
00107   MovingHistogramImageFilter();
00108   ~MovingHistogramImageFilter() {};
00109   
00111   void  ThreadedGenerateData (const OutputImageRegionType& 
00112                               outputRegionForThread,
00113                               int threadId) ;
00114 
00115   void PrintSelf(std::ostream& os, Indent indent) const;
00116 
00122   virtual THistogram NewHistogram();
00123 
00125   KernelType m_Kernel ;
00126 
00127   // store the added and removed pixel offset in a list
00128   OffsetMapType m_AddedOffsets;
00129   OffsetMapType m_RemovedOffsets;
00130 
00131   // store the offset of the kernel to initialize the histogram
00132   OffsetListType m_KernelOffsets;
00133 
00134   typename itk::FixedArray< int, ImageDimension > m_Axes;
00135 
00136   unsigned long m_PixelsPerTranslation;
00137 
00138 #ifndef zigzag
00139   // declare the type used to store the histogram
00140   typedef THistogram HistogramType;
00141 
00142   void pushHistogram(HistogramType &histogram, 
00143          const OffsetListType* addedList,
00144          const OffsetListType* removedList,
00145          const RegionType &inputRegion,
00146          const RegionType &kernRegion,
00147          const InputImageType* inputImage,
00148          const IndexType currentIdx);
00149 
00150   void printHist(const HistogramType &H);
00151 
00152   void GetDirAndOffset(const IndexType LineStart, 
00153            const IndexType PrevLineStart,
00154            const int ImageDimension,
00155            OffsetType &LineOffset,
00156            OffsetType &Changes,
00157            int &LineDirection);
00158 
00159 #endif
00160 
00161 private:
00162   MovingHistogramImageFilter(const Self&); //purposely not implemented
00163   void operator=(const Self&); //purposely not implemented
00164 
00165   class DirectionCost {
00166     public :
00167     DirectionCost( int dimension, int count )
00168       {
00169       m_Dimension = dimension;
00170       m_Count = count;
00171       }
00172     
00177     inline bool operator< ( const DirectionCost &dc ) const
00178       {
00179       if( m_Count > dc.m_Count )
00180         { return true; }
00181       else if( m_Count < dc.m_Count )
00182   { return false; }
00183       else //if (m_Count == dc.m_Count) 
00184   { return m_Dimension > dc.m_Dimension; }
00185       }
00187 
00188     int m_Dimension;
00189     int m_Count;
00190   };
00191 
00192 } ; // end of class
00193 
00194 } // end namespace itk
00195   
00196 #ifndef ITK_MANUAL_INSTANTIATION
00197 #include "itkMovingHistogramImageFilter.txx"
00198 #endif
00199 
00200 #endif
00201 
00202 
00203 

Generated at Fri Sep 8 03:43:56 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000