Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkOtsuSegmentationFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkOtsuSegmentationFilter_h
14 #define mitkOtsuSegmentationFilter_h
15 
16 //#include "MitkSBExports.h"
17 #include <mitkITKImageImport.h>
18 #include <mitkImage.h>
19 #include <mitkImageToImageFilter.h>
20 
21 #include <itkImage.h>
22 
24 
25 namespace mitk
26 {
39  {
40  public:
41  typedef unsigned short OutputPixelType;
42  typedef itk::Image<OutputPixelType, 3> itkOutputImageType;
44 
46  itkFactorylessNewMacro(Self);
47  itkCloneMacro(Self);
48 
50  itkGetMacro(NumberOfThresholds, unsigned int);
51 
60  void SetNumberOfThresholds(unsigned int number)
61  {
62  if (number < 1)
63  {
64  MITK_WARN << "Tried to set an invalid number of thresholds in the OtsuSegmentationFilter.";
65  return;
66  }
67  m_NumberOfThresholds = number;
68  }
69 
75  void SetValleyEmphasis(bool useValley) { m_ValleyEmphasis = useValley; }
76 
82  void SetNumberOfBins(unsigned int number)
83  {
84  if (number < 1)
85  {
86  MITK_WARN << "Tried to set an invalid number of bins in the OtsuSegmentationFilter.";
87  return;
88  }
89  m_NumberOfBins = number;
90  }
91 
92  protected:
95  void GenerateData() override;
96  // virtual void GenerateOutputInformation();
97 
98  private:
99  unsigned int m_NumberOfThresholds;
100  bool m_ValleyEmphasis;
101  unsigned int m_NumberOfBins;
102 
103  }; // class
104 
105 } // namespace
106 #endif
#define MITKSEGMENTATION_EXPORT
Pipelined import of itk::Image.
Superclass of all classes having one or more Images as input and generating Images as output.
A filter that performs a multiple threshold otsu image segmentation.
mitk::ITKImageImport< itkOutputImageType > ImageConverterType
void GenerateData() override
mitkClassMacro(OtsuSegmentationFilter, ImageToImageFilter)
void SetNumberOfThresholds(unsigned int number)
Sets the number of thresholds for Otsu's method.
void SetValleyEmphasis(bool useValley)
Enables or disables valley emphasis in the Otsu threshold computation.
void SetNumberOfBins(unsigned int number)
Sets the number of histogram bins for Otsu's threshold computation.
itk::Image< OutputPixelType, 3 > itkOutputImageType
#define MITK_WARN
Log a warning message.
Definition: mitkLog.h:365
Find image slices visible on a given plane.