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: 2007/04/20 13:36:35 $
00007   Version:   $Revision: 1.12 $
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 
00157   typedef itk::Image< TPosteriorsPrecisionType, 
00158        itkGetStaticConstMacro(Dimension) >                ExtractedComponentImageType;
00159 
00161   typedef ImageToImageFilter< 
00162                    ExtractedComponentImageType, 
00163                    ExtractedComponentImageType  >         SmoothingFilterType;
00164   typedef typename SmoothingFilterType::Pointer           SmoothingFilterPointer;
00165 
00168   void SetSmoothingFilter( SmoothingFilterType * );
00169   itkGetMacro( SmoothingFilter, SmoothingFilterPointer );
00171 
00173   itkSetMacro( NumberOfSmoothingIterations, unsigned int );
00174   itkGetMacro( NumberOfSmoothingIterations, unsigned int );
00176 
00177 #ifdef ITK_USE_CONCEPT_CHECKING
00178 
00179   itkConceptMacro(UnsignedIntConvertibleToLabelsCheck,
00180     (Concept::Convertible<unsigned int, TLabelsType>));
00181   itkConceptMacro(PosteriorsAdditiveOperatorsCheck,
00182     (Concept::AdditiveOperators<TPosteriorsPrecisionType>));
00183   itkConceptMacro(IntConvertibleToPosteriorsCheck,
00184     (Concept::Convertible<int, TPosteriorsPrecisionType>));
00185   itkConceptMacro(InputHasNumericTraitsCheck,
00186     (Concept::HasNumericTraits<typename InputPixelType::ValueType>));
00187   itkConceptMacro(PosteriorsHasNumericTraitsCheck,
00188     (Concept::HasNumericTraits<TPosteriorsPrecisionType>));
00189   itkConceptMacro(PriorsHasNumericTraitsCheck,
00190     (Concept::HasNumericTraits<TPriorsPrecisionType>));
00191   itkConceptMacro(InputPriorsPosteriorsMultiplyOperatorCheck,
00192     (Concept::MultiplyOperator<typename InputPixelType::ValueType,
00193                                PriorsPixelType, PosteriorsPixelType>));
00194 
00196 #endif
00197 
00198 protected:
00199 
00200   BayesianClassifierImageFilter();
00201   virtual ~BayesianClassifierImageFilter() {}
00202   void PrintSelf(std::ostream& os, Indent indent) const;
00203 
00205   virtual void GenerateData();
00206 
00208   virtual void AllocateOutputs();
00209 
00210 
00212   virtual void ComputeBayesRule();
00213   virtual void NormalizeAndSmoothPosteriors();
00214   virtual void ClassifyBasedOnPosteriors();
00215   PosteriorsImageType *GetPosteriorImage();
00217 
00218 private:
00219 
00220   BayesianClassifierImageFilter(const Self&); //purposely not implemented
00221   void operator=(const Self&); //purposely not implemented
00222 
00224   bool m_UserProvidedPriors;
00225 
00227   bool m_UserProvidedSmoothingFilter;
00228 
00230   SmoothingFilterPointer  m_SmoothingFilter;
00231 
00233   unsigned int m_NumberOfSmoothingIterations;
00234 
00235 };
00236 
00237 } // end namespace itk
00238 
00239 
00240 #ifndef ITK_MANUAL_INSTANTIATION
00241 #include "itkBayesianClassifierImageFilter.txx"
00242 #endif
00243 
00244 #endif
00245 

Generated at Tue Jul 29 19:08:52 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000