ITK  5.1.0
Insight Toolkit
itkHistogramThresholdCalculator.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  * 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 
19 #ifndef itkHistogramThresholdCalculator_h
20 #define itkHistogramThresholdCalculator_h
21 
22 #include "itkObject.h"
23 #include "itkObjectFactory.h"
24 #include "itkNumericTraits.h"
26 #include "itkProgressReporter.h"
27 
28 namespace itk
29 {
30 
46 template <typename THistogram, typename TOutput>
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_ASSIGN(HistogramThresholdCalculator);
51 
57 
59  itkNewMacro(Self);
60 
63 
65  using HistogramType = THistogram;
66 
68  using OutputType = TOutput;
70 
71  void
72  SetInput(const HistogramType * input)
73  {
74  // Process object is not const-correct so the const_cast is required here
75  this->ProcessObject::SetNthInput(0, const_cast<HistogramType *>(input));
76  }
77 
78  const HistogramType *
79  GetInput() const
80  {
81  if (this->GetNumberOfInputs() < 1)
82  {
83  return nullptr;
84  }
85  return static_cast<const HistogramType *>(this->ProcessObject::GetInput(0));
86  }
87 
90  {
91  if (this->GetNumberOfOutputs() < 1)
92  {
93  return nullptr;
94  }
95  return static_cast<DecoratedOutputType *>(this->ProcessObject::GetOutput(0));
96  }
97 
100  {
102  }
103 
104  const OutputType &
106  {
107  if (this->GetNumberOfOutputs() < 1)
108  {
109  itkExceptionMacro(<< "No output available.");
110  }
111  return static_cast<DecoratedOutputType *>(this->ProcessObject::GetOutput(0))->Get();
112  }
113 
114 protected:
116  {
118  this->ProcessObject::SetNthOutput(0, this->MakeOutput(0));
119  }
120  ~HistogramThresholdCalculator() override = default;
122 };
123 
124 } // end namespace itk
125 
126 #endif
itk::SimpleDataObjectDecorator
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Definition: itkSimpleDataObjectDecorator.h:66
itkObjectFactory.h
itk::ProcessObject::SetNthOutput
virtual void SetNthOutput(DataObjectPointerArraySizeType num, DataObject *output)
itk::HistogramThresholdCalculator::GetInput
const HistogramType * GetInput() const
Definition: itkHistogramThresholdCalculator.h:79
itk::HistogramThresholdCalculator::HistogramThresholdCalculator
HistogramThresholdCalculator()
Definition: itkHistogramThresholdCalculator.h:115
itk::HistogramThresholdCalculator::HistogramType
THistogram HistogramType
Definition: itkHistogramThresholdCalculator.h:65
itkProgressReporter.h
itk::ProcessObject::GetOutput
DataObject * GetOutput(const DataObjectIdentifierType &key)
itk::SmartPointer< Self >
itk::ProcessObject::DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Definition: itkProcessObject.h:193
itk::ProcessObject::SetInput
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
itk::ProcessObject::ProcessObject
ProcessObject()
itk::HistogramThresholdCalculator::DecoratedOutputType
SimpleDataObjectDecorator< OutputType > DecoratedOutputType
Definition: itkHistogramThresholdCalculator.h:69
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::SimpleDataObjectDecorator::New
static Pointer New()
itk::HistogramThresholdCalculator::~HistogramThresholdCalculator
~HistogramThresholdCalculator() override=default
itk::SmartPointer::GetPointer
ObjectType * GetPointer() const noexcept
Definition: itkSmartPointer.h:140
itk::HistogramThresholdCalculator::MakeOutput
DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType) override
Make a DataObject of the correct type to used as the specified output.
Definition: itkHistogramThresholdCalculator.h:99
itk::HistogramThresholdCalculator::OutputType
TOutput OutputType
Definition: itkHistogramThresholdCalculator.h:68
itk::ProcessObject::GetNumberOfOutputs
DataObjectPointerArraySizeType GetNumberOfOutputs() const
Get the size of the output container.
itk::HistogramThresholdCalculator::SetInput
void SetInput(const HistogramType *input)
Definition: itkHistogramThresholdCalculator.h:72
itk::HistogramThresholdCalculator
Base class to compute a threshold value based on the histogram of an image.
Definition: itkHistogramThresholdCalculator.h:47
itkObject.h
itk::ProcessObject::GetNumberOfInputs
DataObjectPointerArraySizeType GetNumberOfInputs() const
Get the size of the input container.
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::ProcessObject::MakeOutput
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
itk::HistogramThresholdCalculator::GetOutput
DecoratedOutputType * GetOutput()
Definition: itkHistogramThresholdCalculator.h:89
itk::HistogramThresholdCalculator::GetThreshold
const OutputType & GetThreshold()
Definition: itkHistogramThresholdCalculator.h:105
itk::ProcessObject::SetNthInput
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
itkNumericTraits.h
itkSimpleDataObjectDecorator.h
itk::ProcessObject::SetNumberOfRequiredOutputs
virtual void SetNumberOfRequiredOutputs(DataObjectPointerArraySizeType _arg)
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.