ITK  4.4.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 <class THistogram, class 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 0;
79  }
80  return static_cast< const HistogramType * >( this->ProcessObject::GetInput(0) );
81  }
82 
83  DecoratedOutputType * GetOutput()
84  {
85  if ( this->GetNumberOfOutputs() < 1 )
86  {
87  return 0;
88  }
89  return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) );
90  }
91 
92  using Superclass::MakeOutput;
94  {
95  return DecoratedOutputType::New().GetPointer();
96  }
97 
98  const OutputType & GetThreshold()
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
125