00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSampleClassifierFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-05-02 05:43:58 $ 00007 Version: $Revision: 1.1 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkSampleClassifierFilter_h 00018 #define __itkSampleClassifierFilter_h 00019 00020 #include <vector> 00021 00022 #include "itkMembershipSample.h" 00023 #include "itkMembershipFunctionBase.h" 00024 #include "itkDecisionRule.h" 00025 #include "itkProcessObject.h" 00026 #include "itkSimpleDataObjectDecorator.h" 00027 00028 namespace itk { 00029 namespace Statistics { 00030 00040 template< class TSample > 00041 class ITK_EXPORT SampleClassifierFilter : 00042 public ProcessObject 00043 { 00044 public: 00046 typedef SampleClassifierFilter Self; 00047 typedef ProcessObject Superclass; 00048 typedef SmartPointer< Self > Pointer; 00049 typedef SmartPointer<const Self> ConstPointer; 00050 00052 itkTypeMacro(SampleClassifierFilter, ProcessObject); 00053 itkNewMacro(Self); 00055 00057 typedef TSample SampleType; 00058 00060 typedef MembershipSample< SampleType > MembershipSampleType; 00061 typedef typename MembershipSampleType::Pointer MembershipSampleObjectPointer; 00062 00064 typedef typename SampleType::MeasurementType MeasurementType; 00065 typedef typename SampleType::MeasurementVectorType MeasurementVectorType; 00066 00068 typedef MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType; 00069 typedef typename MembershipFunctionType::ConstPointer MembershipFunctionPointer; 00070 typedef std::vector< MembershipFunctionPointer > MembershipFunctionVectorType; 00071 typedef SimpleDataObjectDecorator< 00072 MembershipFunctionVectorType > MembershipFunctionVectorObjectType; 00073 typedef typename 00074 MembershipFunctionVectorObjectType::Pointer MembershipFunctionVectorObjectPointer; 00075 00077 typedef Array< double > MembershipFunctionsWeightsArrayType; 00078 00079 typedef SimpleDataObjectDecorator< 00080 MembershipFunctionsWeightsArrayType > MembershipFunctionsWeightsArrayObjectType; 00081 typedef typename 00082 MembershipFunctionsWeightsArrayObjectType::Pointer MembershipFunctionsWeightsArrayPointer; 00083 00084 typedef unsigned long ClassLabelType; 00085 typedef std::vector< ClassLabelType > ClassLabelVectorType; 00086 typedef SimpleDataObjectDecorator< 00087 ClassLabelVectorType > ClassLabelVectorObjectType; 00088 typedef ClassLabelVectorObjectType::Pointer ClassLabelVectorObjectPointer; 00089 00090 00092 typedef DecisionRule DecisionRuleType; 00093 typedef DecisionRuleType::ConstPointer DecisionRulePointer; 00094 00096 void SetInput(const SampleType * sample); 00097 const SampleType * GetInput() const; 00099 00101 const MembershipSampleType * GetOutput() const; 00102 00106 itkSetMacro( NumberOfClasses, unsigned int ); 00107 itkGetConstMacro( NumberOfClasses, unsigned int ); 00109 00111 itkSetConstObjectMacro( DecisionRule, DecisionRuleType ); 00112 itkGetConstObjectMacro( DecisionRule, DecisionRuleType ); 00114 00118 void SetClassLabels(const ClassLabelVectorObjectType * classLabels ); 00119 00123 void SetMembershipFunctions(const MembershipFunctionVectorObjectType * membershipFunctions ); 00124 00126 void SetMembershipFunctionsWeightsArray(const MembershipFunctionsWeightsArrayObjectType * weightsArray ); 00127 00128 00129 protected: 00130 SampleClassifierFilter(); 00131 virtual ~SampleClassifierFilter() {} 00132 void PrintSelf(std::ostream& os, Indent indent) const; 00133 00134 SampleClassifierFilter(const Self&); //purposely not implemented 00135 void operator=(const Self&); //purposely not implemented 00136 00137 00139 void GenerateData(); 00140 00147 virtual DataObjectPointer MakeOutput(unsigned int idx); 00148 00149 private: 00150 00151 unsigned int m_NumberOfClasses; 00152 00154 DecisionRulePointer m_DecisionRule; 00155 00156 }; // end of class 00157 00158 00159 } // end of namespace Statistics 00160 } // end of namespace itk 00161 00162 00163 #ifndef ITK_MANUAL_INSTANTIATION 00164 #include "itkSampleClassifierFilter.txx" 00165 #endif 00166 00167 #endif 00168