Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBayesianClassifierImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBayesianClassifierImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-02-25 18:28:14 $
00007   Version:   $Revision: 1.13 $
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 __itkBayesianClassifierImageFilter_h
00018 #define __itkBayesianClassifierImageFilter_h
00019 
00020 #include "itkVectorImage.h"
00021 #include "itkImageToImageFilter.h"
00022 #include "itkMaximumDecisionRule.h"
00023 #include "itkImageRegionIterator.h"
00024 #include "itkImageRegionConstIterator.h"
00025 
00026 namespace itk
00027 {
00028   
00079 template < class TInputVectorImage, class TLabelsType=unsigned char, 
00080            class TPosteriorsPrecisionType=double, class TPriorsPrecisionType=double >
00081 class ITK_EXPORT BayesianClassifierImageFilter :
00082     public ImageToImageFilter< 
00083               TInputVectorImage, Image< TLabelsType, 
00084               ::itk::GetImageDimension< TInputVectorImage >::ImageDimension > >
00085 {
00086 public:
00088   typedef BayesianClassifierImageFilter     Self;
00089   typedef ImageToImageFilter< 
00090     TInputVectorImage,
00091     Image< TLabelsType, 
00092            ::itk::GetImageDimension< 
00093     TInputVectorImage >::ImageDimension > > Superclass;
00094   typedef SmartPointer<Self>                Pointer;
00095   typedef SmartPointer<const Self>          ConstPointer;
00096 
00098   itkNewMacro( Self );
00099 
00101   itkTypeMacro( BayesianClassifierImageFilter, ImageToImageFilter );
00102 
00104   typedef typename Superclass::InputImageType        InputImageType;
00105 
00107   itkStaticConstMacro( Dimension, unsigned int, 
00108                        ::itk::GetImageDimension< InputImageType >::ImageDimension );
00109 
00110   typedef Image< TLabelsType, 
00111           itkGetStaticConstMacro(Dimension) >        OutputImageType;
00112   typedef typename InputImageType::ConstPointer      InputImagePointer;
00113   typedef typename OutputImageType::Pointer          OutputImagePointer;
00114   typedef typename InputImageType::RegionType        ImageRegionType;
00115   
00117   typedef ImageRegionConstIterator< InputImageType > InputImageIteratorType;
00118   typedef ImageRegionIterator< OutputImageType >     OutputImageIteratorType;
00119 
00121   typedef typename InputImageType::PixelType              InputPixelType;
00122   typedef typename OutputImageType::PixelType             OutputPixelType;
00123 
00128   typedef VectorImage< TPriorsPrecisionType, 
00129      itkGetStaticConstMacro(Dimension) >                  PriorsImageType;
00130   typedef typename PriorsImageType::PixelType             PriorsPixelType;
00131   typedef typename PriorsImageType::Pointer               PriorsImagePointer;
00132   typedef ImageRegionConstIterator< PriorsImageType >     PriorsImageIteratorType;
00133 
00137   typedef TInputVectorImage                               MembershipImageType;
00138   typedef typename MembershipImageType::PixelType         MembershipPixelType;
00139   typedef typename MembershipImageType::Pointer           MembershipImagePointer;
00140   typedef ImageRegionConstIterator< MembershipImageType > MembershipImageIteratorType;
00141 
00146   typedef VectorImage< TPosteriorsPrecisionType, 
00147      itkGetStaticConstMacro(Dimension) >                  PosteriorsImageType;
00148   typedef typename PosteriorsImageType::PixelType         PosteriorsPixelType;
00149   typedef typename PosteriorsImageType::Pointer           PosteriorsImagePointer;
00150   typedef ImageRegionIterator< PosteriorsImageType >      PosteriorsImageIteratorType;
00151 
00153   typedef MaximumDecisionRule                             DecisionRuleType;
00154   typedef DecisionRuleType::Pointer                       DecisionRulePointer;
00155 
00156   typedef typename Superclass::DataObjectPointer          DataObjectPointer;
00157 
00159   typedef itk::Image< TPosteriorsPrecisionType, 
00160        itkGetStaticConstMacro(Dimension) >                ExtractedComponentImageType;
00161 
00163   typedef ImageToImageFilter< 
00164                    ExtractedComponentImageType, 
00165                    ExtractedComponentImageType  >         SmoothingFilterType;
00166   typedef typename SmoothingFilterType::Pointer           SmoothingFilterPointer;
00167 
00170   void SetSmoothingFilter( SmoothingFilterType * );
00171   itkGetMacro( SmoothingFilter, SmoothingFilterPointer );
00173 
00175   itkSetMacro( NumberOfSmoothingIterations, unsigned int );
00176   itkGetMacro( NumberOfSmoothingIterations, unsigned int );
00178 
00180   virtual DataObjectPointer MakeOutput(unsigned int idx);
00181 
00182 #ifdef ITK_USE_CONCEPT_CHECKING
00183 
00184   itkConceptMacro(UnsignedIntConvertibleToLabelsCheck,
00185     (Concept::Convertible<unsigned int, TLabelsType>));
00186   itkConceptMacro(PosteriorsAdditiveOperatorsCheck,
00187     (Concept::AdditiveOperators<TPosteriorsPrecisionType>));
00188   itkConceptMacro(IntConvertibleToPosteriorsCheck,
00189     (Concept::Convertible<int, TPosteriorsPrecisionType>));
00190   itkConceptMacro(InputHasNumericTraitsCheck,
00191     (Concept::HasNumericTraits<typename InputPixelType::ValueType>));
00192   itkConceptMacro(PosteriorsHasNumericTraitsCheck,
00193     (Concept::HasNumericTraits<TPosteriorsPrecisionType>));
00194   itkConceptMacro(PriorsHasNumericTraitsCheck,
00195     (Concept::HasNumericTraits<TPriorsPrecisionType>));
00196   itkConceptMacro(InputPriorsPosteriorsMultiplyOperatorCheck,
00197     (Concept::MultiplyOperator<typename InputPixelType::ValueType,
00198                                PriorsPixelType, PosteriorsPixelType>));
00199 
00201 #endif
00202 
00203 protected:
00204 
00205   BayesianClassifierImageFilter();
00206   virtual ~BayesianClassifierImageFilter() {}
00207   void PrintSelf(std::ostream& os, Indent indent) const;
00208 
00210   virtual void GenerateData();
00211 
00213   virtual void AllocateOutputs();
00214   virtual void GenerateOutputInformation(void);
00216 
00218   virtual void ComputeBayesRule();
00219   virtual void NormalizeAndSmoothPosteriors();
00220   virtual void ClassifyBasedOnPosteriors();
00221   PosteriorsImageType *GetPosteriorImage();
00223 
00224 private:
00225 
00226   BayesianClassifierImageFilter(const Self&); //purposely not implemented
00227   void operator=(const Self&); //purposely not implemented
00228 
00230   bool m_UserProvidedPriors;
00231 
00233   bool m_UserProvidedSmoothingFilter;
00234 
00236   SmoothingFilterPointer  m_SmoothingFilter;
00237 
00239   unsigned int m_NumberOfSmoothingIterations;
00240 
00241 };
00242 
00243 } // end namespace itk
00244 
00245 
00246 #ifndef ITK_MANUAL_INSTANTIATION
00247 #include "itkBayesianClassifierImageFilter.txx"
00248 #endif
00249 
00250 #endif
00251 

Generated at Sat Feb 28 12:00:15 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000