ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageClassifierFilter.h
Go to the documentation of this file.
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 __itkImageClassifierFilter_h
00019 #define __itkImageClassifierFilter_h
00020 
00021 #include <vector>
00022 
00023 #include "itkMembershipFunctionBase.h"
00024 #include "itkDecisionRule.h"
00025 #include "itkImageToImageFilter.h"
00026 #include "itkSimpleDataObjectDecorator.h"
00027 
00028 namespace itk
00029 {
00030 namespace Statistics
00031 {
00047 template< class TSample, class TInputImage, class TOutputImage >
00048 class ITK_EXPORT ImageClassifierFilter:
00049   public ImageToImageFilter< TInputImage, TOutputImage >
00050 {
00051 public:
00053   typedef ImageClassifierFilter                           Self;
00054   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00055   typedef SmartPointer< Self >                            Pointer;
00056   typedef SmartPointer< const Self >                      ConstPointer;
00057 
00059   itkTypeMacro(ImageClassifierFilter, ImageToImagefilter);
00060   itkNewMacro(Self);
00062 
00064   typedef           TInputImage            InputImageType;
00065   typedef           TOutputImage           OutputImageType;
00066   typedef typename TInputImage::PixelType  InputPixelType;
00067   typedef typename TOutputImage::PixelType OutputPixelType;
00068 
00070   typedef typename TInputImage::Pointer  InputImagePointer;
00071   typedef typename TOutputImage::Pointer OutputImagePointer;
00072 
00073   typedef typename TInputImage::SizeType    InputSizeType;
00074   typedef typename TInputImage::IndexType   InputIndexType;
00075   typedef typename TInputImage::RegionType  InputImageRegionType;
00076   typedef typename TOutputImage::SizeType   OutputSizeType;
00077   typedef typename TOutputImage::IndexType  OutputIndexType;
00078   typedef typename TOutputImage::RegionType OutputImageRegionType;
00079 
00081   itkStaticConstMacro(InputImageDimension, unsigned int,
00082                       TInputImage::ImageDimension);
00083   itkStaticConstMacro(OutputImageDimension, unsigned int,
00084                       TOutputImage::ImageDimension);
00086 
00088   typedef TSample SampleType;
00089 
00091   typedef typename SampleType::MeasurementType       MeasurementType;
00092   typedef typename SampleType::MeasurementVectorType MeasurementVectorType;
00093 
00095   typedef MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType;
00096   typedef typename MembershipFunctionType::ConstPointer   MembershipFunctionPointer;
00097   typedef std::vector< MembershipFunctionPointer >        MembershipFunctionVectorType;
00098   typedef SimpleDataObjectDecorator<
00099     MembershipFunctionVectorType >                        MembershipFunctionVectorObjectType;
00100   typedef typename
00101   MembershipFunctionVectorObjectType::Pointer MembershipFunctionVectorObjectPointer;
00102 
00104   typedef Array< double > MembershipFunctionsWeightsArrayType;
00105 
00106   typedef SimpleDataObjectDecorator<
00107     MembershipFunctionsWeightsArrayType >                 MembershipFunctionsWeightsArrayObjectType;
00108   typedef typename
00109   MembershipFunctionsWeightsArrayObjectType::Pointer MembershipFunctionsWeightsArrayPointer;
00110 
00112   typedef IdentifierType                ClassLabelType;
00113   typedef std::vector< ClassLabelType > ClassLabelVectorType;
00114   typedef SimpleDataObjectDecorator<
00115     ClassLabelVectorType >                            ClassLabelVectorObjectType;
00116   typedef ClassLabelVectorObjectType::Pointer ClassLabelVectorObjectPointer;
00117 
00119   typedef DecisionRule                   DecisionRuleType;
00120   typedef DecisionRuleType::ConstPointer DecisionRulePointer;
00121 
00123   void SetImage(const InputImageType *image);
00124 
00125   const InputImageType *  GetImage() const;
00126 
00130   itkSetMacro(NumberOfClasses, unsigned int);
00131   itkGetConstMacro(NumberOfClasses, unsigned int);
00133 
00135   itkSetConstObjectMacro(DecisionRule, DecisionRuleType);
00136   itkGetConstObjectMacro(DecisionRule, DecisionRuleType);
00138 
00142   void SetClassLabels(const ClassLabelVectorObjectType *classLabels);
00143 
00147   void SetMembershipFunctions(const MembershipFunctionVectorObjectType *membershipFunctions);
00148 
00150   void SetMembershipFunctionsWeightsArray(const MembershipFunctionsWeightsArrayObjectType *weightsArray);
00151 
00152 protected:
00153   ImageClassifierFilter();
00154   virtual ~ImageClassifierFilter() {}
00155   void PrintSelf(std::ostream & os, Indent indent) const;
00156 
00157   ImageClassifierFilter(const Self &); //purposely not implemented
00158   void operator=(const Self &);        //purposely not implemented
00159 
00161   void GenerateData();
00162 
00163 private:
00164 
00165   unsigned int m_NumberOfClasses;
00166 
00168   DecisionRulePointer m_DecisionRule;
00169 };  // end of class
00170 } // end of namespace Statistics
00171 } // end of namespace itk
00172 
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174 #include "itkImageClassifierFilter.hxx"
00175 #endif
00176 
00177 #endif
00178