ITK  5.4.0
Insight Toolkit
itkMaskedMovingHistogramImageFilter.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 itkMaskedMovingHistogramImageFilter_h
19#define itkMaskedMovingHistogramImageFilter_h
20
23#include <list>
24#include <map>
25#include <set>
26
27namespace itk
28{
42template <typename TInputImage, typename TMaskImage, typename TOutputImage, typename TKernel, typename THistogram>
43class ITK_TEMPLATE_EXPORT MaskedMovingHistogramImageFilter
44 : public MovingHistogramImageFilterBase<TInputImage, TOutputImage, TKernel>
45{
46public:
47 ITK_DISALLOW_COPY_AND_MOVE(MaskedMovingHistogramImageFilter);
48
54
56 itkNewMacro(Self);
57
59 itkOverrideGetNameOfClassMacro(MaskedMovingHistogramImageFilter);
60
62 using InputImageType = TInputImage;
63 using OutputImageType = TOutputImage;
64 using MaskImageType = TMaskImage;
68 using PixelType = typename TInputImage::PixelType;
69 using OffsetType = typename TInputImage::OffsetType;
70 using typename Superclass::OutputImageRegionType;
71 using OutputPixelType = typename TOutputImage::PixelType;
72 using InputPixelType = typename TInputImage::PixelType;
73 using MaskPixelType = typename MaskImageType::PixelType;
74 using HistogramType = THistogram;
75
77 void
79 {
80 // Process object is not const-correct so the const casting is required.
81 this->SetNthInput(1, const_cast<TMaskImage *>(input));
82 }
83
85 MaskImageType *
87 {
88 return static_cast<MaskImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
89 }
90
92 void
94 {
95 this->SetInput(input);
96 }
97
99 void
101 {
102 this->SetMaskImage(input);
103 }
104
106 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
107
109 using KernelType = TKernel;
110
112 using KernelIteratorType = typename KernelType::ConstIterator;
113
116
117 using OffsetListType = typename std::list<OffsetType>;
118
119 using OffsetMapType = typename std::map<OffsetType, OffsetListType, Functor::LexicographicCompare>;
120
124
125 void
126 AllocateOutputs() override;
127
129 using Superclass::MakeOutput;
132
133 itkSetMacro(FillValue, OutputPixelType);
134 itkGetConstMacro(FillValue, OutputPixelType);
135
136 itkSetMacro(MaskValue, MaskPixelType);
137 itkGetConstMacro(MaskValue, MaskPixelType);
138
139 itkSetMacro(BackgroundMaskValue, MaskPixelType);
140 itkGetConstMacro(BackgroundMaskValue, MaskPixelType);
141
142 void
144
145 itkGetConstMacro(GenerateOutputMask, bool);
146 itkBooleanMacro(GenerateOutputMask);
147
149 virtual void
150 ConfigureHistogram(THistogram &)
151 {}
152
153protected:
156
158 void
159 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
160
161
162 void
163 PrintSelf(std::ostream & os, Indent indent) const override;
164
165 void
167 const OffsetListType * addedList,
168 const OffsetListType * removedList,
169 const RegionType & inputRegion,
170 const RegionType & kernRegion,
171 const InputImageType * inputImage,
172 const MaskImageType * maskImage,
173 const IndexType currentIdx);
174
175private:
176 bool m_GenerateOutputMask{};
177
178 OutputPixelType m_FillValue{};
179
180 MaskPixelType m_MaskValue{};
181
182 MaskPixelType m_BackgroundMaskValue{};
183}; // end of class
184} // end namespace itk
185
186#ifndef ITK_MANUAL_INSTANTIATION
187# include "itkMaskedMovingHistogramImageFilter.hxx"
188#endif
189
190#endif
typename TInputImage::RegionType RegionType
typename TInputImage::SizeType SizeType
typename TInputImage::PixelType InputPixelType
typename TInputImage::SizeType RadiusType
typename TInputImage::IndexType IndexType
typename TOutputImage::PixelType OutputPixelType
typename TInputImage::OffsetType OffsetType
Base class for all data objects in ITK.
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
void pushHistogram(HistogramType &histogram, const OffsetListType *addedList, const OffsetListType *removedList, const RegionType &inputRegion, const RegionType &kernRegion, const InputImageType *inputImage, const MaskImageType *maskImage, const IndexType currentIdx)
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void PrintSelf(std::ostream &os, Indent indent) const override
~MaskedMovingHistogramImageFilter() override=default
Implements a generic moving histogram algorithm.
typename std::map< OffsetType, OffsetListType, Functor::LexicographicCompare > OffsetMapType
typename KernelType::ConstIterator KernelIteratorType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....