ITK  6.0.0
Insight Toolkit
itkBayesianClassifierImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
80 template <typename TInputVectorImage,
81  typename TLabelsType = unsigned char,
82  typename TPosteriorsPrecisionType = double,
83  typename TPriorsPrecisionType = double>
84 class ITK_TEMPLATE_EXPORT BayesianClassifierImageFilter
85  : public ImageToImageFilter<TInputVectorImage, Image<TLabelsType, TInputVectorImage::ImageDimension>>
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_MOVE(BayesianClassifierImageFilter);
89 
93 
96 
98  itkNewMacro(Self);
99 
101  itkOverrideGetNameOfClassMacro(BayesianClassifierImageFilter);
102 
104  using typename Superclass::InputImageType;
105 
107  static constexpr unsigned int Dimension = InputImageType::ImageDimension;
108 
113 
117 
119  using InputPixelType = typename InputImageType::PixelType;
121 
130 
134  using MembershipImageType = TInputVectorImage;
135  using MembershipPixelType = typename MembershipImageType::PixelType;
138 
147 
151 
152  using typename Superclass::DataObjectPointer;
153 
156 
159 
161 
164  void
165  SetSmoothingFilter(SmoothingFilterType *);
166  itkGetConstMacro(SmoothingFilter, SmoothingFilterPointer);
170  virtual void
171  SetPriors(const PriorsImageType *);
172 
174  itkSetMacro(NumberOfSmoothingIterations, unsigned int);
175  itkGetConstMacro(NumberOfSmoothingIterations, unsigned int);
180  using Superclass::MakeOutput;
182  MakeOutput(DataObjectPointerArraySizeType idx) override;
183 
184 #ifdef ITK_USE_CONCEPT_CHECKING
185  // Begin concept checking
186  itkConceptMacro(UnsignedIntConvertibleToLabelsCheck, (Concept::Convertible<unsigned int, TLabelsType>));
187  itkConceptMacro(PosteriorsAdditiveOperatorsCheck, (Concept::AdditiveOperators<TPosteriorsPrecisionType>));
188  itkConceptMacro(IntConvertibleToPosteriorsCheck, (Concept::Convertible<int, TPosteriorsPrecisionType>));
190  itkConceptMacro(PosteriorsHasNumericTraitsCheck, (Concept::HasNumericTraits<TPosteriorsPrecisionType>));
193  InputPriorsPosteriorsMultiplyOperatorCheck,
195  // End concept checking
196 #endif
197 
198 protected:
200  ~BayesianClassifierImageFilter() override = default;
201  void
202  PrintSelf(std::ostream & os, Indent indent) const override;
203 
204  void
205  GenerateData() override;
206 
207  void
208  GenerateOutputInformation() override;
209 
213  virtual void
214  ComputeBayesRule();
215 
217  virtual void
218  NormalizeAndSmoothPosteriors();
219 
221  virtual void
222  ClassifyBasedOnPosteriors();
223 
226  GetPosteriorImage();
227 
228 private:
229  bool m_UserProvidedPriors{ false };
230 
231  bool m_UserProvidedSmoothingFilter{ false };
232 
233  SmoothingFilterPointer m_SmoothingFilter{};
234 
235  unsigned int m_NumberOfSmoothingIterations{ 0 };
236 };
237 } // end namespace itk
238 
239 #ifndef ITK_MANUAL_INSTANTIATION
240 # include "itkBayesianClassifierImageFilter.hxx"
241 #endif
242 
243 #endif
itkMaximumDecisionRule.h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::BayesianClassifierImageFilter::PosteriorsImagePointer
typename PosteriorsImageType::Pointer PosteriorsImagePointer
Definition: itkBayesianClassifierImageFilter.h:145
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:717
itk::BayesianClassifierImageFilter::PosteriorsPixelType
typename PosteriorsImageType::PixelType PosteriorsPixelType
Definition: itkBayesianClassifierImageFilter.h:144
itk::VectorImage
Templated n-dimensional vector image class.
Definition: itkImageAlgorithm.h:29
itk::BayesianClassifierImageFilter::MembershipPixelType
typename MembershipImageType::PixelType MembershipPixelType
Definition: itkBayesianClassifierImageFilter.h:135
itk::BayesianClassifierImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkBayesianClassifierImageFilter.h:119
itk::SmartPointer< Self >
itkImageRegionIterator.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ProcessObject::DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Definition: itkProcessObject.h:194
itk::BayesianClassifierImageFilter::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkBayesianClassifierImageFilter.h:111
itk::BayesianClassifierImageFilter::ImageRegionType
typename InputImageType::RegionType ImageRegionType
Definition: itkBayesianClassifierImageFilter.h:112
itk::BayesianClassifierImageFilter::MembershipImagePointer
typename MembershipImageType::Pointer MembershipImagePointer
Definition: itkBayesianClassifierImageFilter.h:136
itkVectorImage.h
itk::BayesianClassifierImageFilter::MembershipImageType
TInputVectorImage MembershipImageType
Definition: itkBayesianClassifierImageFilter.h:134
itk::BayesianClassifierImageFilter::InputImagePointer
typename InputImageType::ConstPointer InputImagePointer
Definition: itkBayesianClassifierImageFilter.h:110
itk::ImageRegionIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionIterator.h:80
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::BayesianClassifierImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkBayesianClassifierImageFilter.h:120
itk::Statistics::MaximumDecisionRule
A decision rule that returns the class label with the largest discriminant score.
Definition: itkMaximumDecisionRule.h:41
itkImageToImageFilter.h
itk::VariableLengthVector
Represents an array whose length can be defined at run-time.
Definition: itkConstantBoundaryCondition.h:28
itk::Concept::MultiplyOperator
Definition: itkConceptChecking.h:422
itk::Image::PixelType
TPixel PixelType
Definition: itkImage.h:108
itk::BayesianClassifierImageFilter
Performs Bayesian Classification on an image.
Definition: itkBayesianClassifierImageFilter.h:84
itk::BayesianClassifierImageFilter::SmoothingFilterPointer
typename SmoothingFilterType::Pointer SmoothingFilterPointer
Definition: itkBayesianClassifierImageFilter.h:160
itk::Concept::AdditiveOperators
Definition: itkConceptChecking.h:361
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Concept::Convertible
Definition: itkConceptChecking.h:217
itk::BayesianClassifierImageFilter::PriorsPixelType
typename PriorsImageType::PixelType PriorsPixelType
Definition: itkBayesianClassifierImageFilter.h:127
itk::ImageRegionConstIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionConstIterator.h:109
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::BayesianClassifierImageFilter::PriorsImagePointer
typename PriorsImageType::Pointer PriorsImagePointer
Definition: itkBayesianClassifierImageFilter.h:128
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44