ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkBayesianClassifierInitializationImageFilter.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 __itkBayesianClassifierInitializationImageFilter_h
00019 #define __itkBayesianClassifierInitializationImageFilter_h
00020 
00021 #include "itkVectorImage.h"
00022 #include "itkVectorContainer.h"
00023 #include "itkImageToImageFilter.h"
00024 #include "itkImageRegionIterator.h"
00025 #include "itkMembershipFunctionBase.h"
00026 
00027 namespace itk
00028 {
00075 template< class TInputImage, class TProbabilityPrecisionType = float >
00076 class ITK_EXPORT BayesianClassifierInitializationImageFilter:
00077   public
00078   ImageToImageFilter< TInputImage, VectorImage< TProbabilityPrecisionType,
00079                                                 ::itk::GetImageDimension< TInputImage >::ImageDimension > >
00080 {
00081 public:
00083   typedef BayesianClassifierInitializationImageFilter Self;
00084   typedef TInputImage                                 InputImageType;
00085   typedef TProbabilityPrecisionType                   ProbabilityPrecisionType;
00086 
00088   itkStaticConstMacro(Dimension, unsigned int,
00089                       ::itk::GetImageDimension< InputImageType >::ImageDimension);
00090 
00091   typedef VectorImage< ProbabilityPrecisionType,
00092                        itkGetStaticConstMacro(Dimension) >                   OutputImageType;
00093   typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
00094   typedef SmartPointer< Self >                                  Pointer;
00095   typedef SmartPointer< const Self >                            ConstPointer;
00096 
00098   itkNewMacro(Self);
00099 
00101   itkTypeMacro(BayesianClassifierInitializationImageFilter, ImageToImageFilter);
00102 
00104   typedef ImageRegionConstIterator< InputImageType > InputImageIteratorType;
00105 
00107   typedef typename InputImageType::PixelType  InputPixelType;
00108   typedef typename OutputImageType::PixelType OutputPixelType;
00109 
00113   typedef VectorImage< ProbabilityPrecisionType,
00114                        itkGetStaticConstMacro(Dimension) >             MembershipImageType;
00115   typedef typename MembershipImageType::PixelType    MembershipPixelType;
00116   typedef typename MembershipImageType::Pointer      MembershipImagePointer;
00117   typedef ImageRegionIterator< MembershipImageType > MembershipImageIteratorType;
00118 
00120   typedef Vector< InputPixelType, 1 > MeasurementVectorType;
00121 
00123   typedef Statistics::MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType;
00124   typedef typename MembershipFunctionType::Pointer                    MembershipFunctionPointer;
00125 
00127   typedef VectorContainer< unsigned int,
00128                            MembershipFunctionPointer >  MembershipFunctionContainerType;
00129   typedef typename MembershipFunctionContainerType::Pointer
00130   MembershipFunctionContainerPointer;
00131 
00137   virtual void SetMembershipFunctions(MembershipFunctionContainerType
00138                                       *densityFunctionContainer);
00139 
00140   itkGetObjectMacro(MembershipFunctionContainer, MembershipFunctionContainerType);
00141 
00143   itkSetMacro(NumberOfClasses, unsigned int);
00144   itkGetConstMacro(NumberOfClasses, unsigned int);
00146 
00147   virtual void GenerateOutputInformation();
00148 
00149 #ifdef ITK_USE_CONCEPT_CHECKING
00150 
00151   itkConceptMacro( InputMultiplyOperatorCheck,
00152                    ( Concept::MultiplyOperator< InputPixelType > ) );
00153   itkConceptMacro( DoubleConvertibleToProbabilityCheck,
00154                    ( Concept::Convertible< double, TProbabilityPrecisionType > ) );
00155   itkConceptMacro( InputHasNumericTraitsCheck,
00156                    ( Concept::HasNumericTraits< InputPixelType > ) );
00157   itkConceptMacro( ProbabilityHasNumericTraitsCheck,
00158                    ( Concept::HasNumericTraits< TProbabilityPrecisionType > ) );
00159   itkConceptMacro( DoublePlusInputCheck,
00160                    ( Concept::AdditiveOperators< double, InputPixelType > ) );
00161 
00163 #endif
00164 protected:
00165   BayesianClassifierInitializationImageFilter();
00166   virtual ~BayesianClassifierInitializationImageFilter() {}
00167   void PrintSelf(std::ostream & os, Indent indent) const;
00169 
00175   virtual void InitializeMembershipFunctions();
00176 
00179   virtual void GenerateData();
00180 
00181 private:
00182   BayesianClassifierInitializationImageFilter(const Self &); //purposely not
00183                                                              // implemented
00184   void operator=(const Self &);                              //purposely not
00185                                                              // implemented
00186 
00187   bool         m_UserSuppliesMembershipFunctions;
00188   unsigned int m_NumberOfClasses;
00189 
00190   typename MembershipFunctionContainerType::Pointer m_MembershipFunctionContainer;
00191 };
00192 } // end namespace itk
00193 
00194 #ifndef ITK_MANUAL_INSTANTIATION
00195 #include "itkBayesianClassifierInitializationImageFilter.hxx"
00196 #endif
00197 
00198 #endif
00199