ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 00019 #ifndef __itkHistogramThresholdCalculator_h 00020 #define __itkHistogramThresholdCalculator_h 00021 00022 #include "itkObject.h" 00023 #include "itkObjectFactory.h" 00024 #include "itkNumericTraits.h" 00025 #include "itkSimpleDataObjectDecorator.h" 00026 #include "itkProgressReporter.h" 00027 00028 namespace itk 00029 { 00030 00045 template <class THistogram, class TOutput> 00046 class ITK_EXPORT HistogramThresholdCalculator : public ProcessObject 00047 { 00048 public: 00050 typedef HistogramThresholdCalculator Self; 00051 typedef ProcessObject Superclass; 00052 typedef SmartPointer<Self> Pointer; 00053 typedef SmartPointer<const Self> ConstPointer; 00054 00056 itkNewMacro(Self); 00057 00059 itkTypeMacro(HistogramThresholdCalculator, ProcessObject); 00060 00062 typedef THistogram HistogramType; 00063 00065 typedef TOutput OutputType; 00066 typedef SimpleDataObjectDecorator<OutputType> DecoratedOutputType; 00067 00068 void SetInput( const HistogramType * input ) 00069 { 00070 // Process object is not const-correct so the const_cast is required here 00071 this->ProcessObject::SetNthInput( 0, const_cast< HistogramType * >( input ) ); 00072 } 00073 00074 const HistogramType * GetInput() const 00075 { 00076 if ( this->GetNumberOfInputs() < 1 ) 00077 { 00078 return 0; 00079 } 00080 return static_cast< const HistogramType * >( this->ProcessObject::GetInput(0) ); 00081 } 00082 00083 DecoratedOutputType * GetOutput() 00084 { 00085 if ( this->GetNumberOfOutputs() < 1 ) 00086 { 00087 return 0; 00088 } 00089 return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) ); 00090 } 00091 00092 using Superclass::MakeOutput; 00093 virtual typename DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType) 00094 { 00095 return DecoratedOutputType::New().GetPointer(); 00096 } 00097 00098 const OutputType & GetThreshold() 00099 { 00100 if ( this->GetNumberOfOutputs() < 1 ) 00101 { 00102 itkExceptionMacro(<<"No output available."); 00103 } 00104 return static_cast< DecoratedOutputType * >( this->ProcessObject::GetOutput(0) )->Get(); 00105 } 00106 00107 protected: 00108 HistogramThresholdCalculator() 00109 { 00110 this->ProcessObject::SetNumberOfRequiredOutputs(1); 00111 this->ProcessObject::SetNthOutput( 0, this->MakeOutput(0) ); 00112 } 00113 virtual ~HistogramThresholdCalculator() {}; 00114 using ProcessObject::SetInput; 00115 00116 private: 00117 HistogramThresholdCalculator(const Self&); //purposely not implemented 00118 void operator=(const Self&); //purposely not implemented 00119 00120 }; 00121 00122 } // end namespace itk 00123 00124 #endif 00125