00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkMovingHistogramImageFilterBase_h
00018 #define __itkMovingHistogramImageFilterBase_h
00019
00020 #include "itkKernelImageFilter.h"
00021 #include <list>
00022 #include <map>
00023 #include <set>
00024
00025 namespace itk {
00026
00090 template<class TInputImage, class TOutputImage, class TKernel >
00091 class ITK_EXPORT MovingHistogramImageFilterBase :
00092 public KernelImageFilter<TInputImage, TOutputImage, TKernel>
00093 {
00094 public:
00096 typedef MovingHistogramImageFilterBase Self;
00097 typedef KernelImageFilter<TInputImage, TOutputImage, TKernel> Superclass;
00098 typedef SmartPointer<Self> Pointer;
00099 typedef SmartPointer<const Self> ConstPointer;
00100
00102 itkNewMacro(Self);
00103
00105 itkTypeMacro(MovingHistogramImageFilterBase,
00106 KernelImageFilter);
00107
00109 typedef TInputImage InputImageType;
00110 typedef TOutputImage OutputImageType;
00111 typedef typename TInputImage::RegionType RegionType;
00112 typedef typename TInputImage::SizeType SizeType;
00113 typedef typename TInputImage::IndexType IndexType;
00114 typedef typename TInputImage::PixelType PixelType;
00115 typedef typename TInputImage::OffsetType OffsetType;
00116 typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00117 typedef typename TOutputImage::PixelType OutputPixelType;
00118
00120 itkStaticConstMacro(ImageDimension, unsigned int,
00121 TInputImage::ImageDimension);
00122
00124 typedef TKernel KernelType;
00125
00127 typedef typename KernelType::ConstIterator KernelIteratorType;
00128
00130 typedef typename KernelType::SizeType RadiusType;
00131
00132 typedef typename std::list< OffsetType > OffsetListType;
00133
00134 typedef typename std::map< OffsetType, OffsetListType, typename OffsetType::LexicographicCompare > OffsetMapType;
00135
00137 void SetKernel( const KernelType& kernel );
00138
00139 itkGetMacro(PixelsPerTranslation, unsigned long);
00140
00141 protected:
00142 MovingHistogramImageFilterBase();
00143 ~MovingHistogramImageFilterBase() {};
00144
00145 void PrintSelf(std::ostream& os, Indent indent) const;
00146
00147 void GetDirAndOffset(const IndexType LineStart,
00148 const IndexType PrevLineStart,
00149 OffsetType &LineOffset,
00150 OffsetType &Changes,
00151 int &LineDirection);
00152
00153
00154 OffsetMapType m_AddedOffsets;
00155 OffsetMapType m_RemovedOffsets;
00156
00157
00158 OffsetListType m_KernelOffsets;
00159
00160 FixedArray< int, itkGetStaticConstMacro(ImageDimension) > m_Axes;
00161
00162 unsigned long m_PixelsPerTranslation;
00163
00164
00165 private:
00166 MovingHistogramImageFilterBase(const Self&);
00167 void operator=(const Self&);
00168
00169 class DirectionCost
00170 {
00171 public :
00172 DirectionCost( int dimension, int count )
00173 {
00174 m_Dimension = dimension;
00175 m_Count = count;
00176 }
00177
00182 inline bool operator< ( const DirectionCost &dc ) const
00183 {
00184 if( m_Count > dc.m_Count )
00185 { return true; }
00186 else if( m_Count < dc.m_Count )
00187 { return false; }
00188 else
00189 { return m_Dimension > dc.m_Dimension; }
00190 }
00192
00193 int m_Dimension;
00194 int m_Count;
00195 };
00196
00197 };
00198
00199 }
00200
00201 #ifndef ITK_MANUAL_INSTANTIATION
00202 #include "itkMovingHistogramImageFilterBase.txx"
00203 #endif
00204
00205 #endif
00206