ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkBayesianClassifierImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkBayesianClassifierImageFilter_h
19 #define itkBayesianClassifierImageFilter_h
20 
21 #include "itkVectorImage.h"
22 #include "itkImageToImageFilter.h"
23 #include "itkMaximumDecisionRule.h"
24 #include "itkImageRegionIterator.h"
25 
26 namespace itk
27 {
79 template< typename TInputVectorImage, typename TLabelsType = unsigned char,
80  typename TPosteriorsPrecisionType = double, typename TPriorsPrecisionType = double >
81 class ITK_TEMPLATE_EXPORT BayesianClassifierImageFilter:
82  public ImageToImageFilter<
83  TInputVectorImage, Image< TLabelsType,
84  TInputVectorImage ::ImageDimension > >
85 {
86 public:
89  typedef ImageToImageFilter<
90  TInputVectorImage,
92 
95 
97  itkNewMacro(Self);
98 
101 
103  typedef typename Superclass::InputImageType InputImageType;
104 
106  itkStaticConstMacro(Dimension, unsigned int,
107  InputImageType ::ImageDimension);
108 
109  typedef Image< TLabelsType,
110  itkGetStaticConstMacro(Dimension) > OutputImageType;
111  typedef typename InputImageType::ConstPointer InputImagePointer;
113  typedef typename InputImageType::RegionType ImageRegionType;
114 
118 
120  typedef typename InputImageType::PixelType InputPixelType;
122 
127  typedef VectorImage< TPriorsPrecisionType,
128  itkGetStaticConstMacro(Dimension) > PriorsImageType;
132 
136  typedef TInputVectorImage MembershipImageType;
137  typedef typename MembershipImageType::PixelType MembershipPixelType;
138  typedef typename MembershipImageType::Pointer MembershipImagePointer;
140 
145  typedef VectorImage< TPosteriorsPrecisionType,
146  itkGetStaticConstMacro(Dimension) > PosteriorsImageType;
150 
154 
155  typedef typename Superclass::DataObjectPointer DataObjectPointer;
156 
158  typedef itk::Image< TPosteriorsPrecisionType,
159  itkGetStaticConstMacro(Dimension) > ExtractedComponentImageType;
160 
162  typedef ImageToImageFilter<
165 
167 
170  void SetSmoothingFilter(SmoothingFilterType *);
171  itkGetConstMacro(SmoothingFilter, SmoothingFilterPointer);
173 
175  virtual void SetPriors(const PriorsImageType *);
176 
178  itkSetMacro(NumberOfSmoothingIterations, unsigned int);
179  itkGetConstMacro(NumberOfSmoothingIterations, unsigned int);
181 
184  using Superclass::MakeOutput;
185  virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
186 
187 #ifdef ITK_USE_CONCEPT_CHECKING
188  // Begin concept checking
189  itkConceptMacro( UnsignedIntConvertibleToLabelsCheck,
191  itkConceptMacro( PosteriorsAdditiveOperatorsCheck,
193  itkConceptMacro( IntConvertibleToPosteriorsCheck,
195  itkConceptMacro( InputHasNumericTraitsCheck,
197  itkConceptMacro( PosteriorsHasNumericTraitsCheck,
199  itkConceptMacro( PriorsHasNumericTraitsCheck,
201  itkConceptMacro( InputPriorsPosteriorsMultiplyOperatorCheck,
202  ( Concept::MultiplyOperator< typename InputPixelType::ValueType,
204  // End concept checking
205 #endif
206 
207 protected:
208 
210  virtual ~BayesianClassifierImageFilter() ITK_OVERRIDE {}
211  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
212 
213  virtual void GenerateData() ITK_OVERRIDE;
214 
215  virtual void GenerateOutputInformation(void) ITK_OVERRIDE;
216 
220  virtual void ComputeBayesRule();
221 
223  virtual void NormalizeAndSmoothPosteriors();
224 
226  virtual void ClassifyBasedOnPosteriors();
227 
229  PosteriorsImageType * GetPosteriorImage();
230 
231 private:
232 
233  ITK_DISALLOW_COPY_AND_ASSIGN(BayesianClassifierImageFilter);
234 
235 
236  bool m_UserProvidedPriors;
237 
238  bool m_UserProvidedSmoothingFilter;
239 
240  SmoothingFilterPointer m_SmoothingFilter;
241 
242  unsigned int m_NumberOfSmoothingIterations;
243 };
244 } // end namespace itk
245 
246 #ifndef ITK_MANUAL_INSTANTIATION
247 #include "itkBayesianClassifierImageFilter.hxx"
248 #endif
249 
250 #endif
ImageRegionConstIterator< PriorsImageType > PriorsImageIteratorType
Light weight base class for most itk classes.
ImageRegionConstIterator< InputImageType > InputImageIteratorType
ImageRegionConstIterator< MembershipImageType > MembershipImageIteratorType
Image< TLabelsType, itkGetStaticConstMacro(Dimension) > OutputImageType
ImageToImageFilter< TInputVectorImage, Image< TLabelsType, TInputVectorImage::ImageDimension > > Superclass
Templated n-dimensional vector image class.
itk::Image< TPosteriorsPrecisionType, itkGetStaticConstMacro(Dimension) > ExtractedComponentImageType
PosteriorsImageType::PixelType PosteriorsPixelType
TPixel PixelType
Definition: itkImage.h:89
MembershipImageType::PixelType MembershipPixelType
VectorImage< TPosteriorsPrecisionType, itkGetStaticConstMacro(Dimension) > PosteriorsImageType
Represents an array whose length can be defined at run-time.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Performs Bayesian Classification on an image.
A multi-dimensional iterator templated over image type that walks a region of pixels.
ImageRegionIterator< PosteriorsImageType > PosteriorsImageIteratorType
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Statistics::MaximumDecisionRule DecisionRuleType
ImageRegionIterator< OutputImageType > OutputImageIteratorType
Base class for filters that take an image as input and produce an image as output.
A decision rule that returns the class label with the largest discriminant score. ...
VectorImage< TPriorsPrecisionType, itkGetStaticConstMacro(Dimension) > PriorsImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ImageToImageFilter< ExtractedComponentImageType, ExtractedComponentImageType > SmoothingFilterType
#define itkConceptMacro(name, concept)
Templated n-dimensional image class.
Definition: itkImage.h:75
A multi-dimensional iterator templated over image type that walks a region of pixels.