ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkMovingHistogramImageFilterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkMovingHistogramImageFilterBase_h
19 #define itkMovingHistogramImageFilterBase_h
20 
21 #include "itkKernelImageFilter.h"
22 #include <list>
23 #include <map>
24 #include <set>
25 
26 namespace itk
27 {
89 template< typename TInputImage, typename TOutputImage, typename TKernel >
91  public KernelImageFilter< TInputImage, TOutputImage, TKernel >
92 {
93 public:
99 
101  itkNewMacro(Self);
102 
104  itkTypeMacro(MovingHistogramImageFilterBase,
106 
108  typedef TInputImage InputImageType;
109  typedef TOutputImage OutputImageType;
110  typedef typename TInputImage::RegionType RegionType;
111  typedef typename TInputImage::SizeType SizeType;
112  typedef typename TInputImage::IndexType IndexType;
113  typedef typename TInputImage::PixelType PixelType;
114  typedef typename TInputImage::OffsetType OffsetType;
116  typedef typename TOutputImage::PixelType OutputPixelType;
117 
119  itkStaticConstMacro(ImageDimension, unsigned int,
120  TInputImage::ImageDimension);
121 
123  typedef TKernel KernelType;
124 
126  typedef typename KernelType::ConstIterator KernelIteratorType;
127 
129  typedef typename KernelType::SizeType RadiusType;
130 
131  typedef typename std::list< OffsetType > OffsetListType;
132 
133  typedef typename std::map< OffsetType, OffsetListType, typename OffsetType::LexicographicCompare > OffsetMapType;
134 
136  void SetKernel(const KernelType & kernel) ITK_OVERRIDE;
137 
138  itkGetConstMacro(PixelsPerTranslation, SizeValueType);
139 
140 protected:
143 
144  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
145 
146  void GetDirAndOffset(const IndexType LineStart,
147  const IndexType PrevLineStart,
148  OffsetType & LineOffset,
149  OffsetType & Changes,
150  int & LineDirection);
151 
152  // store the added and removed pixel offset in a list
155 
156  // store the offset of the kernel to initialize the histogram
158 
160 
162 
163 private:
164  MovingHistogramImageFilterBase(const Self &) ITK_DELETE_FUNCTION;
165  void operator=(const Self &) ITK_DELETE_FUNCTION;
166 
168  {
169 public:
170  DirectionCost(int dimension, int count)
171  {
172  m_Dimension = dimension;
173  m_Count = count;
174  }
175 
180  inline bool operator<(const DirectionCost & dc) const
181  {
182  if ( m_Count > dc.m_Count )
183  { return true; }
184  else if ( m_Count < dc.m_Count )
185  { return false; }
186  else //if (m_Count == dc.m_Count)
187  { return m_Dimension > dc.m_Dimension; }
188  }
190 
192  int m_Count;
193  };
194 }; // end of class
195 } // end namespace itk
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198 #include "itkMovingHistogramImageFilterBase.hxx"
199 #endif
200 
201 #endif
KernelImageFilter< TInputImage, TOutputImage, TKernel > Superclass
FixedArray< int, itkGetStaticConstMacro(ImageDimension) > m_Axes
void GetDirAndOffset(const IndexType LineStart, const IndexType PrevLineStart, OffsetType &LineOffset, OffsetType &Changes, int &LineDirection)
void PrintSelf(std::ostream &os, Indent indent) const override
Superclass::OutputImageRegionType OutputImageRegionType
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
A base class for all the filters working on an arbitrary shaped neighborhood.
std::map< OffsetType, OffsetListType, typename OffsetType::LexicographicCompare > OffsetMapType
void SetKernel(const KernelType &kernel) override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Superclass::OutputImageRegionType OutputImageRegionType
Implements a generic moving histogram algorithm.