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
23#include <list>
24#include <map>
25#include <set>
26
27namespace itk
28{
90template <typename TInputImage, typename TOutputImage, typename TKernel>
91class ITK_TEMPLATE_EXPORT MovingHistogramImageFilterBase : public KernelImageFilter<TInputImage, TOutputImage, TKernel>
92{
93public:
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;
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
141protected:
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
166private:
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 }
200 };
201}; // end of class
202} // end namespace itk
203
204#ifndef ITK_MANUAL_INSTANTIATION
205# include "itkMovingHistogramImageFilterBase.hxx"
206#endif
207
208#endif
typename TInputImage::RegionType RegionType
typename TInputImage::SizeType SizeType
typename TInputImage::SizeType RadiusType
typename TInputImage::IndexType IndexType
typename TOutputImage::PixelType OutputPixelType
typename TInputImage::OffsetType OffsetType
Base class for all process objects that output image data.
TOutputImage OutputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
A base class for all the filters working on an arbitrary shaped neighborhood.
Implements a generic moving histogram algorithm.
typename std::map< OffsetType, OffsetListType, Functor::LexicographicCompare > OffsetMapType
typename KernelType::ConstIterator KernelIteratorType
void GetDirAndOffset(const IndexType LineStart, const IndexType PrevLineStart, OffsetType &LineOffset, OffsetType &Changes, int &LineDirection)
~MovingHistogramImageFilterBase() override=default
void SetKernel(const KernelType &kernel) override
void PrintSelf(std::ostream &os, Indent indent) const override
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:557