ITK  5.0.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:
87  ITK_DISALLOW_COPY_AND_ASSIGN(BayesianClassifierImageFilter);
88 
92  TInputVectorImage,
94 
97 
99  itkNewMacro(Self);
100 
103 
105  using InputImageType = typename Superclass::InputImageType;
106 
108  static constexpr unsigned int Dimension = InputImageType ::ImageDimension;
109 
110  using OutputImageType = Image< TLabelsType,
112  using InputImagePointer = typename InputImageType::ConstPointer;
115 
119 
121  using InputPixelType = typename InputImageType::PixelType;
123 
128  using PriorsImageType = VectorImage< TPriorsPrecisionType,
133 
137  using MembershipImageType = TInputVectorImage;
138  using MembershipPixelType = typename MembershipImageType::PixelType;
139  using MembershipImagePointer = typename MembershipImageType::Pointer;
141 
146  using PosteriorsImageType = VectorImage< TPosteriorsPrecisionType,
151 
155 
156  using DataObjectPointer = typename Superclass::DataObjectPointer;
157 
159  using ExtractedComponentImageType = itk::Image< TPosteriorsPrecisionType,
161 
166 
168 
171  void SetSmoothingFilter(SmoothingFilterType *);
172  itkGetConstMacro(SmoothingFilter, SmoothingFilterPointer);
174 
176  virtual void SetPriors(const PriorsImageType *);
177 
179  itkSetMacro(NumberOfSmoothingIterations, unsigned int);
180  itkGetConstMacro(NumberOfSmoothingIterations, unsigned int);
182 
185  using Superclass::MakeOutput;
186  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
187 
188 #ifdef ITK_USE_CONCEPT_CHECKING
189  // Begin concept checking
190  itkConceptMacro( UnsignedIntConvertibleToLabelsCheck,
192  itkConceptMacro( PosteriorsAdditiveOperatorsCheck,
194  itkConceptMacro( IntConvertibleToPosteriorsCheck,
196  itkConceptMacro( InputHasNumericTraitsCheck,
198  itkConceptMacro( PosteriorsHasNumericTraitsCheck,
200  itkConceptMacro( PriorsHasNumericTraitsCheck,
202  itkConceptMacro( InputPriorsPosteriorsMultiplyOperatorCheck,
203  ( Concept::MultiplyOperator< typename InputPixelType::ValueType,
205  // End concept checking
206 #endif
207 
208 protected:
209 
211  ~BayesianClassifierImageFilter() override = default;
212  void PrintSelf(std::ostream & os, Indent indent) const override;
213 
214  void GenerateData() override;
215 
216  void GenerateOutputInformation() override;
217 
221  virtual void ComputeBayesRule();
222 
224  virtual void NormalizeAndSmoothPosteriors();
225 
227  virtual void ClassifyBasedOnPosteriors();
228 
230  PosteriorsImageType * GetPosteriorImage();
231 
232 private:
233 
234 
235  bool m_UserProvidedPriors{ false };
236 
237  bool m_UserProvidedSmoothingFilter{ false };
238 
240 
241  unsigned int m_NumberOfSmoothingIterations{ 0 };
242 };
243 } // end namespace itk
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 #include "itkBayesianClassifierImageFilter.hxx"
247 #endif
248 
249 #endif
typename InputImageType::ConstPointer InputImagePointer
TPixel PixelType
Definition: itkImage.h:95
Light weight base class for most itk classes.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
typename PriorsImageType::PixelType PriorsPixelType
typename Superclass::InputImageType InputImageType
Templated n-dimensional vector image class.
Represents an array whose length can be defined at run-time.
Performs Bayesian Classification on an image.
A multi-dimensional iterator templated over image type that walks a region of pixels.
typename OutputImageType::PixelType OutputPixelType
typename InputImageType::RegionType ImageRegionType
typename MembershipImageType::Pointer MembershipImagePointer
typename OutputImageType::Pointer OutputImagePointer
typename PriorsImageType::Pointer PriorsImagePointer
typename MembershipImageType::PixelType MembershipPixelType
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. ...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename PosteriorsImageType::PixelType PosteriorsPixelType
typename PosteriorsImageType::Pointer PosteriorsImagePointer
#define itkConceptMacro(name, concept)
typename SmoothingFilterType::Pointer SmoothingFilterPointer
Templated n-dimensional image class.
Definition: itkImage.h:75
A multi-dimensional iterator templated over image type that walks a region of pixels.
typename InputImageType::PixelType InputPixelType