ITK  4.2.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< class TInputImage, class TOutputImage, class 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;
115  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
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);
137 
138  itkGetConstMacro(PixelsPerTranslation, SizeValueType);
139 
140 protected:
143 
144  void PrintSelf(std::ostream & os, Indent indent) const;
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 private:
163  MovingHistogramImageFilterBase(const Self &); //purposely not implemented
164  void operator=(const Self &); //purposely not implemented
165 
167  {
168 public:
169  DirectionCost(int dimension, int count)
170  {
171  m_Dimension = dimension;
172  m_Count = count;
173  }
174 
179  inline bool operator<(const DirectionCost & dc) const
180  {
181  if ( m_Count > dc.m_Count )
182  { return true; }
183  else if ( m_Count < dc.m_Count )
184  { return false; }
185  else //if (m_Count == dc.m_Count)
186  { return m_Dimension > dc.m_Dimension; }
187  }
189 
191  int m_Count;
192  };
193 }; // end of class
194 } // end namespace itk
195 
196 #ifndef ITK_MANUAL_INSTANTIATION
197 #include "itkMovingHistogramImageFilterBase.hxx"
198 #endif
199 
200 #endif
201