ITK  6.0.0
Insight Toolkit
itkMovingHistogramImageFilterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 : public KernelImageFilter<TInputImage, TOutputImage, TKernel>
92 {
93 public:
94  ITK_DISALLOW_COPY_AND_MOVE(MovingHistogramImageFilterBase);
95 
101 
103  itkNewMacro(Self);
104 
106  itkOverrideGetNameOfClassMacro(MovingHistogramImageFilterBase);
107 
109  using InputImageType = TInputImage;
110  using OutputImageType = TOutputImage;
112  using SizeType = typename TInputImage::SizeType;
114  using PixelType = typename TInputImage::PixelType;
115  using OffsetType = typename TInputImage::OffsetType;
116  using typename Superclass::OutputImageRegionType;
117  using OutputPixelType = typename TOutputImage::PixelType;
118 
120  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
121 
123  using KernelType = TKernel;
124 
126  using KernelIteratorType = typename KernelType::ConstIterator;
127 
130 
131  using OffsetListType = typename std::list<OffsetType>;
132 
133  using OffsetMapType = typename std::map<OffsetType, OffsetListType, Functor::LexicographicCompare>;
134 
136  void
137  SetKernel(const KernelType & kernel) override;
138 
139  itkGetConstMacro(PixelsPerTranslation, SizeValueType);
140 
141 protected:
143  ~MovingHistogramImageFilterBase() override = default;
144 
145  void
146  PrintSelf(std::ostream & os, Indent indent) const override;
147 
148  void
149  GetDirAndOffset(const IndexType LineStart,
150  const IndexType PrevLineStart,
151  OffsetType & LineOffset,
152  OffsetType & Changes,
153  int & LineDirection);
154 
155  // store the added and removed pixel offset in a list
156  OffsetMapType m_AddedOffsets{};
157  OffsetMapType m_RemovedOffsets{};
158 
159  // store the offset of the kernel to initialize the histogram
160  OffsetListType m_KernelOffsets{};
161 
163 
164  SizeValueType m_PixelsPerTranslation{};
165 
166 private:
168  {
169  public:
170  DirectionCost(int dimension, int count)
171  {
172  m_Dimension = dimension;
173  m_Count = count;
174  }
175 
180  inline bool
181  operator<(const DirectionCost & dc) const
182  {
183  if (m_Count > dc.m_Count)
184  {
185  return true;
186  }
187  else if (m_Count < dc.m_Count)
188  {
189  return false;
190  }
191  else // if (m_Count == dc.m_Count)
192  {
193  return m_Dimension > dc.m_Dimension;
194  }
195  }
199  int m_Count;
200  };
201 }; // end of class
202 } // end namespace itk
203 
204 #ifndef ITK_MANUAL_INSTANTIATION
205 # include "itkMovingHistogramImageFilterBase.hxx"
206 #endif
207 
208 #endif
itk::operator<
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:557
itk::BoxImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkBoxImageFilter.h:67
itk::MovingHistogramImageFilterBase< TImageType, TImageType, TKernel >::KernelIteratorType
typename KernelType::ConstIterator KernelIteratorType
Definition: itkMovingHistogramImageFilterBase.h:126
itk::MovingHistogramImageFilterBase::DirectionCost::DirectionCost
DirectionCost(int dimension, int count)
Definition: itkMovingHistogramImageFilterBase.h:170
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkLexicographicCompare.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MovingHistogramImageFilterBase::DirectionCost::m_Dimension
int m_Dimension
Definition: itkMovingHistogramImageFilterBase.h:198
itk::BoxImageFilter::RadiusType
typename TInputImage::SizeType RadiusType
Definition: itkBoxImageFilter.h:73
itk::BoxImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkBoxImageFilter.h:62
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itkKernelImageFilter.h
itk::BoxImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkBoxImageFilter.h:61
itk::MovingHistogramImageFilterBase< TImageType, TImageType, TKernel >::PixelType
typename TImageType ::PixelType PixelType
Definition: itkMovingHistogramImageFilterBase.h:114
itk::MovingHistogramImageFilterBase
Implements a generic moving histogram algorithm.
Definition: itkMovingHistogramImageFilterBase.h:91
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::FixedArray< int, Self::ImageDimension >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::KernelImageFilter< TImageType, TImageType, TKernel >::KernelType
TKernel KernelType
Definition: itkKernelImageFilter.h:71
itk::MovingHistogramImageFilterBase< TImageType, TImageType, TKernel >::OffsetMapType
typename std::map< OffsetType, OffsetListType, Functor::LexicographicCompare > OffsetMapType
Definition: itkMovingHistogramImageFilterBase.h:133
itk::BoxImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkBoxImageFilter.h:60
itk::MovingHistogramImageFilterBase::DirectionCost
Definition: itkMovingHistogramImageFilterBase.h:167
itk::KernelImageFilter
A base class for all the filters working on an arbitrary shaped neighborhood.
Definition: itkKernelImageFilter.h:41
itk::MovingHistogramImageFilterBase< TImageType, TImageType, TKernel >::OffsetListType
typename std::list< OffsetType > OffsetListType
Definition: itkMovingHistogramImageFilterBase.h:131
itk::MovingHistogramImageFilterBase::DirectionCost::m_Count
int m_Count
Definition: itkMovingHistogramImageFilterBase.h:199
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::BoxImageFilter::RegionType
typename TInputImage::RegionType RegionType
Definition: itkBoxImageFilter.h:59