ITK  5.0.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"
23 #include <list>
24 #include <map>
25 #include <set>
26 
27 namespace itk
28 {
90 template< typename TInputImage, typename TOutputImage, typename TKernel >
91 class ITK_TEMPLATE_EXPORT MovingHistogramImageFilterBase:
92  public KernelImageFilter< TInputImage, TOutputImage, TKernel >
93 {
94 public:
95  ITK_DISALLOW_COPY_AND_ASSIGN(MovingHistogramImageFilterBase);
96 
102 
104  itkNewMacro(Self);
105 
107  itkTypeMacro(MovingHistogramImageFilterBase,
109 
111  using InputImageType = TInputImage;
112  using OutputImageType = TOutputImage;
114  using SizeType = typename TInputImage::SizeType;
116  using PixelType = typename TInputImage::PixelType;
117  using OffsetType = typename TInputImage::OffsetType;
118  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
119  using OutputPixelType = typename TOutputImage::PixelType;
120 
122  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
123 
125  using KernelType = TKernel;
126 
128  using KernelIteratorType = typename KernelType::ConstIterator;
129 
132 
133  using OffsetListType = typename std::list< OffsetType >;
134 
135  using OffsetMapType = typename std::map< OffsetType, OffsetListType, Functor::LexicographicCompare >;
136 
138  void SetKernel(const KernelType & kernel) override;
139 
140  itkGetConstMacro(PixelsPerTranslation, SizeValueType);
141 
142 protected:
144  ~MovingHistogramImageFilterBase() override = default;
145 
146  void PrintSelf(std::ostream & os, Indent indent) const override;
147 
148  void GetDirAndOffset(const IndexType LineStart,
149  const IndexType PrevLineStart,
150  OffsetType & LineOffset,
151  OffsetType & Changes,
152  int & LineDirection);
153 
154  // store the added and removed pixel offset in a list
157 
158  // store the offset of the kernel to initialize the histogram
160 
162 
164 
165 private:
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
typename TInputImage::SizeType RadiusType
FixedArray< int, Self::ImageDimension > m_Axes
typename std::map< OffsetType, OffsetListType, Functor::LexicographicCompare > OffsetMapType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename TInputImage::IndexType IndexType
typename TOutputImage::PixelType OutputPixelType
typename TInputImage::RegionType RegionType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:51
typename TInputImage::OffsetType OffsetType
typename OutputImageType::RegionType OutputImageRegionType
typename TInputImage::SizeType SizeType
TOutputImage OutputImageType
A base class for all the filters working on an arbitrary shaped neighborhood.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Implements a generic moving histogram algorithm.