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 #ifndef __itkSampleClassifierFilter_h 00019 #define __itkSampleClassifierFilter_h 00020 00021 #include <vector> 00022 00023 #include "itkMembershipSample.h" 00024 #include "itkMembershipFunctionBase.h" 00025 #include "itkDecisionRule.h" 00026 #include "itkProcessObject.h" 00027 #include "itkSimpleDataObjectDecorator.h" 00028 00029 namespace itk 00030 { 00031 namespace Statistics 00032 { 00043 template< class TSample > 00044 class ITK_EXPORT SampleClassifierFilter: 00045 public ProcessObject 00046 { 00047 public: 00049 typedef SampleClassifierFilter Self; 00050 typedef ProcessObject Superclass; 00051 typedef SmartPointer< Self > Pointer; 00052 typedef SmartPointer< const Self > ConstPointer; 00053 00055 itkTypeMacro(SampleClassifierFilter, ProcessObject); 00056 itkNewMacro(Self); 00058 00060 typedef TSample SampleType; 00061 00063 typedef MembershipSample< SampleType > MembershipSampleType; 00064 typedef typename MembershipSampleType::Pointer MembershipSampleObjectPointer; 00065 00067 typedef typename SampleType::MeasurementType MeasurementType; 00068 typedef typename SampleType::MeasurementVectorType MeasurementVectorType; 00069 00071 typedef MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType; 00072 typedef typename MembershipFunctionType::ConstPointer MembershipFunctionPointer; 00073 typedef std::vector< MembershipFunctionPointer > MembershipFunctionVectorType; 00074 typedef SimpleDataObjectDecorator< 00075 MembershipFunctionVectorType > MembershipFunctionVectorObjectType; 00076 typedef typename 00077 MembershipFunctionVectorObjectType::Pointer MembershipFunctionVectorObjectPointer; 00078 00080 typedef Array< double > MembershipFunctionsWeightsArrayType; 00081 00082 typedef SimpleDataObjectDecorator< 00083 MembershipFunctionsWeightsArrayType > MembershipFunctionsWeightsArrayObjectType; 00084 typedef typename 00085 MembershipFunctionsWeightsArrayObjectType::Pointer MembershipFunctionsWeightsArrayPointer; 00086 00087 typedef IdentifierType ClassLabelType; 00088 typedef std::vector< ClassLabelType > ClassLabelVectorType; 00089 typedef SimpleDataObjectDecorator< 00090 ClassLabelVectorType > ClassLabelVectorObjectType; 00091 typedef ClassLabelVectorObjectType::Pointer ClassLabelVectorObjectPointer; 00092 00094 typedef DecisionRule DecisionRuleType; 00095 typedef DecisionRuleType::ConstPointer DecisionRulePointer; 00096 00098 using Superclass::SetInput; 00099 void SetInput(const SampleType *sample); 00100 00101 const SampleType * GetInput() const; 00102 00104 const MembershipSampleType * GetOutput() const; 00105 00109 itkSetMacro(NumberOfClasses, unsigned int); 00110 itkGetConstMacro(NumberOfClasses, unsigned int); 00112 00114 itkSetConstObjectMacro(DecisionRule, DecisionRuleType); 00115 itkGetConstObjectMacro(DecisionRule, DecisionRuleType); 00117 00121 void SetClassLabels(const ClassLabelVectorObjectType *classLabels); 00122 00126 void SetMembershipFunctions(const MembershipFunctionVectorObjectType *membershipFunctions); 00127 00129 void SetMembershipFunctionsWeightsArray(const MembershipFunctionsWeightsArrayObjectType *weightsArray); 00130 00131 protected: 00132 SampleClassifierFilter(); 00133 virtual ~SampleClassifierFilter() {} 00134 void PrintSelf(std::ostream & os, Indent indent) const; 00135 00136 SampleClassifierFilter(const Self &); //purposely not implemented 00137 void operator=(const Self &); //purposely not implemented 00138 00140 void GenerateData(); 00141 00148 typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; 00149 using Superclass::MakeOutput; 00150 virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx); 00152 00153 private: 00154 00155 unsigned int m_NumberOfClasses; 00156 00158 DecisionRulePointer m_DecisionRule; 00159 }; // end of class 00160 } // end of namespace Statistics 00161 } // end of namespace itk 00162 00163 #ifndef ITK_MANUAL_INSTANTIATION 00164 #include "itkSampleClassifierFilter.hxx" 00165 #endif 00166 00167 #endif 00168