ITK  4.8.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:
54 
56  itkNewMacro(Self);
57 
60 
62  typedef THistogram HistogramType;
63 
65  typedef TOutput OutputType;
67 
68  void SetInput( const HistogramType * input )
69  {
70  // Process object is not const-correct so the const_cast is required here
71  this->ProcessObject::SetNthInput( 0, const_cast< HistogramType * >( input ) );
72  }
73 
74  const HistogramType * GetInput() const
75  {
76  if ( this->GetNumberOfInputs() < 1 )
77  {
78  return ITK_NULLPTR;
79  }
80  return static_cast< const HistogramType * >( this->ProcessObject::GetInput(0) );
81  }
82 
84  {
85  if ( this->GetNumberOfOutputs() < 1 )
86  {
87  return ITK_NULLPTR;
88  }
89  return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) );
90  }
91 
94  {
96  }
97 
99  {
100  if ( this->GetNumberOfOutputs() < 1 )
101  {
102  itkExceptionMacro(<<"No output available.");
103  }
104  return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) )->Get();
105  }
106 
107 protected:
109  {
111  this->ProcessObject::SetNthOutput( 0, this->MakeOutput(0) );
112  }
115 
116 private:
117  HistogramThresholdCalculator(const Self&); //purposely not implemented
118  void operator=(const Self&); //purposely not implemented
119 
120 };
121 
122 } // end namespace itk
123 
124 #endif
virtual void SetNumberOfRequiredOutputs(DataObjectPointerArraySizeType _arg)
Light weight base class for most itk classes.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
ObjectType * GetPointer() const
virtual DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType) override
Make a DataObject of the correct type to used as the specified output.
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...
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
SimpleDataObjectDecorator< OutputType > DecoratedOutputType
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)