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 __itkClassifierBase_h 00019 #define __itkClassifierBase_h 00020 00021 #include "itkLightProcessObject.h" 00022 #include "itkMembershipFunctionBase.h" 00023 #include "itkDecisionRule.h" 00024 00025 #include <vector> 00026 00027 namespace itk 00028 { 00085 template< class TDataContainer > 00086 class ITK_EXPORT ClassifierBase:public LightProcessObject 00087 { 00088 public: 00090 typedef ClassifierBase Self; 00091 typedef LightProcessObject Superclass; 00092 00094 itkTypeMacro(ClassifierBase, LightProcessObject); 00095 00097 itkSetMacro(NumberOfClasses, unsigned int); 00098 00100 itkGetConstReferenceMacro(NumberOfClasses, unsigned int); 00101 00103 typedef typename TDataContainer::ValueType MeasurementVectorType; 00104 00106 typedef Statistics::MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType; 00107 typedef typename MembershipFunctionType::Pointer MembershipFunctionPointer; 00108 00109 typedef std::vector< MembershipFunctionPointer > 00110 MembershipFunctionPointerVector; 00111 00113 typedef Statistics::DecisionRule DecisionRuleType; 00114 00118 void SetDecisionRule(DecisionRuleType *ptrToDecisionRule) 00119 { 00120 m_DecisionRule = ptrToDecisionRule; 00121 } 00122 00124 DecisionRuleType * GetDecisionRule(void) 00125 { 00126 return m_DecisionRule.GetPointer(); 00127 } 00128 00133 const MembershipFunctionType * GetMembershipFunction(unsigned int index) const 00134 { 00135 return m_MembershipFunctions[index].GetPointer(); 00136 } 00137 00139 unsigned int GetNumberOfMembershipFunctions() 00140 { 00141 return static_cast< unsigned int >( m_MembershipFunctions.size() ); 00142 } 00143 00145 unsigned int AddMembershipFunction(MembershipFunctionType *function); 00146 00148 void Update(); 00149 00150 protected: 00151 ClassifierBase(); 00152 ~ClassifierBase(); 00153 void PrintSelf(std::ostream & os, Indent indent) const; 00154 00157 virtual void GenerateData() = 0; 00158 00159 private: 00160 ClassifierBase(const Self &); //purposely not implemented 00161 void operator=(const Self &); //purposely not implemented 00162 00164 unsigned int m_NumberOfClasses; 00165 00167 typename DecisionRuleType::Pointer m_DecisionRule; 00168 00170 MembershipFunctionPointerVector m_MembershipFunctions; 00171 }; // class Classifier 00172 } // namespace itk 00173 00174 #ifndef ITK_MANUAL_INSTANTIATION 00175 #include "itkClassifierBase.hxx" 00176 #endif 00177 00178 #endif 00179