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: 2010-01-30 21:05:25 $
00007   Version:   $Revision: 1.17 $
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   itkGetConstMacro( SmoothingFilter, SmoothingFilterPointer );
00173 
00175   virtual void SetPriors( const PriorsImageType * );
00176 
00178   itkSetMacro( NumberOfSmoothingIterations, unsigned int );
00179   itkGetConstMacro( NumberOfSmoothingIterations, unsigned int );
00181 
00183   virtual DataObjectPointer MakeOutput(unsigned int idx);
00184 
00185 #ifdef ITK_USE_CONCEPT_CHECKING
00186 
00187   itkConceptMacro(UnsignedIntConvertibleToLabelsCheck,
00188     (Concept::Convertible<unsigned int, TLabelsType>));
00189   itkConceptMacro(PosteriorsAdditiveOperatorsCheck,
00190     (Concept::AdditiveOperators<TPosteriorsPrecisionType>));
00191   itkConceptMacro(IntConvertibleToPosteriorsCheck,
00192     (Concept::Convertible<int, TPosteriorsPrecisionType>));
00193   itkConceptMacro(InputHasNumericTraitsCheck,
00194     (Concept::HasNumericTraits<typename InputPixelType::ValueType>));
00195   itkConceptMacro(PosteriorsHasNumericTraitsCheck,
00196     (Concept::HasNumericTraits<TPosteriorsPrecisionType>));
00197   itkConceptMacro(PriorsHasNumericTraitsCheck,
00198     (Concept::HasNumericTraits<TPriorsPrecisionType>));
00199   itkConceptMacro(InputPriorsPosteriorsMultiplyOperatorCheck,
00200     (Concept::MultiplyOperator<typename InputPixelType::ValueType,
00201                                PriorsPixelType, PosteriorsPixelType>));
00202 
00204 #endif
00205 
00206 protected:
00207 
00208   BayesianClassifierImageFilter();
00209   virtual ~BayesianClassifierImageFilter() {}
00210   void PrintSelf(std::ostream& os, Indent indent) const;
00211 
00213   virtual void GenerateData();
00214 
00215   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 Fri Apr 16 17:50:15 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000