ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkBayesianClassifierImageFilter_h 00019 #define __itkBayesianClassifierImageFilter_h 00020 00021 #include "itkVectorImage.h" 00022 #include "itkImageToImageFilter.h" 00023 #include "itkMaximumDecisionRule.h" 00024 #include "itkImageRegionIterator.h" 00025 00026 namespace itk 00027 { 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 00095 typedef SmartPointer< Self > Pointer; 00096 typedef SmartPointer< const Self > ConstPointer; 00097 00099 itkNewMacro(Self); 00100 00102 itkTypeMacro(BayesianClassifierImageFilter, ImageToImageFilter); 00103 00105 typedef typename Superclass::InputImageType InputImageType; 00106 00108 itkStaticConstMacro(Dimension, unsigned int, 00109 ::itk::GetImageDimension< InputImageType >::ImageDimension); 00110 00111 typedef Image< TLabelsType, 00112 itkGetStaticConstMacro(Dimension) > OutputImageType; 00113 typedef typename InputImageType::ConstPointer InputImagePointer; 00114 typedef typename OutputImageType::Pointer OutputImagePointer; 00115 typedef typename InputImageType::RegionType ImageRegionType; 00116 00118 typedef ImageRegionConstIterator< InputImageType > InputImageIteratorType; 00119 typedef ImageRegionIterator< OutputImageType > OutputImageIteratorType; 00120 00122 typedef typename InputImageType::PixelType InputPixelType; 00123 typedef typename OutputImageType::PixelType OutputPixelType; 00124 00129 typedef VectorImage< TPriorsPrecisionType, 00130 itkGetStaticConstMacro(Dimension) > PriorsImageType; 00131 typedef typename PriorsImageType::PixelType PriorsPixelType; 00132 typedef typename PriorsImageType::Pointer PriorsImagePointer; 00133 typedef ImageRegionConstIterator< PriorsImageType > PriorsImageIteratorType; 00134 00138 typedef TInputVectorImage MembershipImageType; 00139 typedef typename MembershipImageType::PixelType MembershipPixelType; 00140 typedef typename MembershipImageType::Pointer MembershipImagePointer; 00141 typedef ImageRegionConstIterator< MembershipImageType > MembershipImageIteratorType; 00142 00147 typedef VectorImage< TPosteriorsPrecisionType, 00148 itkGetStaticConstMacro(Dimension) > PosteriorsImageType; 00149 typedef typename PosteriorsImageType::PixelType PosteriorsPixelType; 00150 typedef typename PosteriorsImageType::Pointer PosteriorsImagePointer; 00151 typedef ImageRegionIterator< PosteriorsImageType > PosteriorsImageIteratorType; 00152 00154 typedef Statistics::MaximumDecisionRule DecisionRuleType; 00155 typedef DecisionRuleType::Pointer DecisionRulePointer; 00156 00157 typedef typename Superclass::DataObjectPointer DataObjectPointer; 00158 00160 typedef itk::Image< TPosteriorsPrecisionType, 00161 itkGetStaticConstMacro(Dimension) > ExtractedComponentImageType; 00162 00164 typedef ImageToImageFilter< 00165 ExtractedComponentImageType, 00166 ExtractedComponentImageType > SmoothingFilterType; 00167 00168 typedef typename SmoothingFilterType::Pointer SmoothingFilterPointer; 00169 00172 void SetSmoothingFilter(SmoothingFilterType *); 00173 00174 itkGetConstMacro(SmoothingFilter, SmoothingFilterPointer); 00175 00177 virtual void SetPriors(const PriorsImageType *); 00178 00180 itkSetMacro(NumberOfSmoothingIterations, unsigned int); 00181 itkGetConstMacro(NumberOfSmoothingIterations, unsigned int); 00183 00185 typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; 00186 using Superclass::MakeOutput; 00187 virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx); 00188 00189 #ifdef ITK_USE_CONCEPT_CHECKING 00190 00191 itkConceptMacro( UnsignedIntConvertibleToLabelsCheck, 00192 ( Concept::Convertible< unsigned int, TLabelsType > ) ); 00193 itkConceptMacro( PosteriorsAdditiveOperatorsCheck, 00194 ( Concept::AdditiveOperators< TPosteriorsPrecisionType > ) ); 00195 itkConceptMacro( IntConvertibleToPosteriorsCheck, 00196 ( Concept::Convertible< int, TPosteriorsPrecisionType > ) ); 00197 itkConceptMacro( InputHasNumericTraitsCheck, 00198 ( Concept::HasNumericTraits< typename InputPixelType::ValueType > ) ); 00199 itkConceptMacro( PosteriorsHasNumericTraitsCheck, 00200 ( Concept::HasNumericTraits< TPosteriorsPrecisionType > ) ); 00201 itkConceptMacro( PriorsHasNumericTraitsCheck, 00202 ( Concept::HasNumericTraits< TPriorsPrecisionType > ) ); 00203 itkConceptMacro( InputPriorsPosteriorsMultiplyOperatorCheck, 00204 ( Concept::MultiplyOperator< typename InputPixelType::ValueType, 00205 PriorsPixelType, PosteriorsPixelType > ) ); 00206 00208 #endif 00209 protected: 00210 00211 BayesianClassifierImageFilter(); 00212 virtual ~BayesianClassifierImageFilter() {} 00213 void PrintSelf(std::ostream & os, Indent indent) const; 00214 00216 virtual void GenerateData(); 00217 00218 virtual void GenerateOutputInformation(void); 00219 00222 virtual void ComputeBayesRule(); 00223 00224 virtual void NormalizeAndSmoothPosteriors(); 00225 00226 virtual void ClassifyBasedOnPosteriors(); 00227 00228 PosteriorsImageType * GetPosteriorImage(); 00229 00230 private: 00231 00232 BayesianClassifierImageFilter(const Self &); //purposely not implemented 00233 void operator=(const Self &); //purposely not implemented 00234 00236 bool m_UserProvidedPriors; 00237 00239 bool m_UserProvidedSmoothingFilter; 00240 00242 SmoothingFilterPointer m_SmoothingFilter; 00243 00245 unsigned int m_NumberOfSmoothingIterations; 00246 }; 00247 } // end namespace itk 00248 00249 #ifndef ITK_MANUAL_INSTANTIATION 00250 #include "itkBayesianClassifierImageFilter.hxx" 00251 #endif 00252 00253 #endif 00254