ITK  6.0.0
Insight Toolkit
itkMultiLabelSTAPLEImageFilter.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 itkMultiLabelSTAPLEImageFilter_h
19#define itkMultiLabelSTAPLEImageFilter_h
20
21#include "itkImage.h"
23
26
27#include "vector"
28#include "itkArray.h"
29#include "itkArray2D.h"
30#include "itkNumericTraits.h"
31
32namespace itk
33{
118template <typename TInputImage, typename TOutputImage = TInputImage, typename TWeights = float>
119class ITK_TEMPLATE_EXPORT MultiLabelSTAPLEImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
120{
121public:
122 ITK_DISALLOW_COPY_AND_MOVE(MultiLabelSTAPLEImageFilter);
123
129
131 itkNewMacro(Self);
132
134 itkOverrideGetNameOfClassMacro(MultiLabelSTAPLEImageFilter);
135
138 using OutputPixelType = typename TOutputImage::PixelType;
139 using InputPixelType = typename TInputImage::PixelType;
140
143 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
144
146 using InputImageType = TInputImage;
147 using OutputImageType = TOutputImage;
150
152 using typename Superclass::OutputImageRegionType;
153
157
159 using WeightsType = TWeights;
162
164 itkGetConstMacro(ElapsedNumberOfIterations, unsigned int);
165
168 void
169 SetMaximumNumberOfIterations(const unsigned int mit)
170 {
171 this->m_MaximumNumberOfIterations = mit;
172 this->m_HasMaximumNumberOfIterations = true;
173 this->Modified();
174 }
175 itkGetConstMacro(MaximumNumberOfIterations, unsigned int);
179 itkGetConstMacro(HasMaximumNumberOfIterations, bool);
180
183 void
185 {
186 if (this->m_HasMaximumNumberOfIterations)
187 {
188 this->m_HasMaximumNumberOfIterations = false;
189 this->Modified();
190 }
191 }
196 itkSetMacro(TerminationUpdateThreshold, TWeights);
197 itkGetConstMacro(TerminationUpdateThreshold, TWeights);
202 void
204 {
205 this->m_LabelForUndecidedPixels = l;
206 this->m_HasLabelForUndecidedPixels = true;
207 this->Modified();
208 }
218 itkGetMacro(LabelForUndecidedPixels, OutputPixelType);
219
221 itkGetMacro(HasLabelForUndecidedPixels, bool);
222
225 void
227 {
228 if (this->m_HasLabelForUndecidedPixels)
229 {
230 this->m_HasLabelForUndecidedPixels = false;
231 this->Modified();
232 }
233 }
242 void
244 {
245 this->m_PriorProbabilities = ppa;
246 this->m_HasPriorProbabilities = true;
247 this->Modified();
248 }
258 itkGetConstReferenceMacro(PriorProbabilities, PriorProbabilitiesType);
259
261 itkGetMacro(HasPriorProbabilities, bool);
262
265 void
267 {
268 if (this->m_HasPriorProbabilities)
269 {
270 this->m_HasPriorProbabilities = false;
271 this->Modified();
272 }
273 }
278 const ConfusionMatrixType &
279 GetConfusionMatrix(const unsigned int i) const
280 {
281 return this->m_ConfusionMatrixArray[i];
282 }
283
284protected:
286 : m_LabelForUndecidedPixels(OutputPixelType{})
287 , m_TerminationUpdateThreshold(1e-5)
288 {}
289 ~MultiLabelSTAPLEImageFilter() override = default;
290
291 void
292 GenerateData() override;
293
294 void
295 PrintSelf(std::ostream &, Indent) const override;
296
298 typename TInputImage::PixelType
300
301 // Override since the filter needs all the data for the algorithm
302 void
304
305 // Override since the filter produces all of its output
306 void
308
309private:
310 size_t m_TotalLabelCount{ 0 };
311
312 OutputPixelType m_LabelForUndecidedPixels{};
313 bool m_HasLabelForUndecidedPixels{ false };
314
315 bool m_HasPriorProbabilities{ false };
316 PriorProbabilitiesType m_PriorProbabilities{};
317
318 void
320
321 std::vector<ConfusionMatrixType> m_ConfusionMatrixArray{};
322 std::vector<ConfusionMatrixType> m_UpdatedConfusionMatrixArray{};
323
324 void
326 void
328
329 bool m_HasMaximumNumberOfIterations{ false };
330 unsigned int m_MaximumNumberOfIterations{ 0 };
331 unsigned int m_ElapsedNumberOfIterations{ 0u };
332
333 TWeights m_TerminationUpdateThreshold{};
334};
335
336} // end namespace itk
337
338#ifndef ITK_MANUAL_INSTANTIATION
339# include "itkMultiLabelSTAPLEImageFilter.hxx"
340#endif
341
342#endif
Array2D class representing a 2D array.
Definition: itkArray2D.h:43
Base class for all data objects in ITK.
A multi-dimensional iterator templated over image type that walks a region of pixels.
A multi-dimensional iterator templated over image type that walks a region of pixels.
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
This filter performs a pixelwise combination of an arbitrary number of input images,...
void PrintSelf(std::ostream &, Indent) const override
const ConfusionMatrixType & GetConfusionMatrix(const unsigned int i) const
void SetMaximumNumberOfIterations(const unsigned int mit)
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::Pointer OutputImagePointer
void SetLabelForUndecidedPixels(const OutputPixelType l)
typename TInputImage::PixelType InputPixelType
~MultiLabelSTAPLEImageFilter() override=default
TInputImage::PixelType ComputeMaximumInputValue()
typename TOutputImage::PixelType OutputPixelType
void EnlargeOutputRequestedRegion(DataObject *) override
void GenerateInputRequestedRegion() override
void SetPriorProbabilities(const PriorProbabilitiesType &ppa)
SmartPointer< Self > Pointer
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....