ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkHistogramThresholdCalculator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
45 template <typename THistogram, typename TOutput>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(HistogramThresholdCalculator);
50 
56 
58  itkNewMacro(Self);
59 
62 
64  using HistogramType = THistogram;
65 
67  using OutputType = TOutput;
69 
70  void SetInput( const HistogramType * input )
71  {
72  // Process object is not const-correct so the const_cast is required here
73  this->ProcessObject::SetNthInput( 0, const_cast< HistogramType * >( input ) );
74  }
75 
76  const HistogramType * GetInput() const
77  {
78  if ( this->GetNumberOfInputs() < 1 )
79  {
80  return nullptr;
81  }
82  return static_cast< const HistogramType * >( this->ProcessObject::GetInput(0) );
83  }
84 
86  {
87  if ( this->GetNumberOfOutputs() < 1 )
88  {
89  return nullptr;
90  }
91  return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) );
92  }
93 
96  {
98  }
99 
101  {
102  if ( this->GetNumberOfOutputs() < 1 )
103  {
104  itkExceptionMacro(<<"No output available.");
105  }
106  return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) )->Get();
107  }
108 
109 protected:
111  {
113  this->ProcessObject::SetNthOutput( 0, this->MakeOutput(0) );
114  }
115  ~HistogramThresholdCalculator() override = default;
117 };
118 
119 } // end namespace itk
120 
121 #endif
virtual void SetNumberOfRequiredOutputs(DataObjectPointerArraySizeType _arg)
Light weight base class for most itk classes.
DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType) override
Make a DataObject of the correct type to used as the specified output.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
ObjectType * GetPointer() const noexcept
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
~HistogramThresholdCalculator() override=default
void SetInput(const HistogramType *input)
DataObjectPointerArraySizeType GetNumberOfInputs() const
Get the size of the input container.
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
DataObjectPointerArraySizeType GetNumberOfOutputs() const
Get the size of the output container.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
Base class to compute a threshold value based on the histogram of an image.
virtual void SetNthOutput(DataObjectPointerArraySizeType num, DataObject *output)
DataObject * GetOutput(const DataObjectIdentifierType &key)