ITK  6.0.0
Insight Toolkit
itkRobustAutomaticThresholdImageFilter.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 itkRobustAutomaticThresholdImageFilter_h
19 #define itkRobustAutomaticThresholdImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
23 
24 namespace itk
25 {
49 template <typename TInputImage, typename TGradientImage = TInputImage, typename TOutputImage = TInputImage>
50 class ITK_TEMPLATE_EXPORT RobustAutomaticThresholdImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(RobustAutomaticThresholdImageFilter);
54 
60 
62  itkNewMacro(Self);
63 
65  itkOverrideGetNameOfClassMacro(RobustAutomaticThresholdImageFilter);
66 
68  using InputImageType = TInputImage;
69  using GradientImageType = TGradientImage;
70 
72  using InputPixelType = typename TInputImage::PixelType;
73  using OutputPixelType = typename TOutputImage::PixelType;
74  using GradientPixelType = typename TGradientImage::PixelType;
75 
80 
87 
89 
91  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
92  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
93 
96  itkSetMacro(OutsideValue, OutputPixelType);
97 
99  itkGetConstMacro(OutsideValue, OutputPixelType);
100 
103  itkSetMacro(InsideValue, OutputPixelType);
104 
106  itkGetConstMacro(InsideValue, OutputPixelType);
107 
109  itkGetConstMacro(Threshold, InputPixelType);
110 
111  itkSetMacro(Pow, double);
112  itkGetConstMacro(Pow, double);
113 
114 #ifdef ITK_USE_CONCEPT_CHECKING
115  // Begin concept checking
116  itkConceptMacro(OutputComparableCheck, (Concept::Comparable<OutputPixelType>));
117  itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
118  // End concept checking
119 #endif
120 
122  void
124  {
125  // Process object is not const-correct so the const casting is required.
126  this->SetNthInput(1, const_cast<GradientImageType *>(input));
127  }
128 
130  GradientImageType *
132  {
133  return static_cast<GradientImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
134  }
135 
137  void
138  SetInput1(TInputImage * input)
139  {
140  this->SetInput(input);
141  }
142 
144  void
146  {
147  this->SetGradientImage(input);
148  }
149 
150 protected:
152  ~RobustAutomaticThresholdImageFilter() override = default;
153  void
154  PrintSelf(std::ostream & os, Indent indent) const override;
155 
156  void
157  GenerateInputRequestedRegion() override;
158 
159  void
160  GenerateData() override;
161 
162 private:
163  double m_Pow{ 1 };
164  InputPixelType m_Threshold{};
165  OutputPixelType m_InsideValue{};
166  OutputPixelType m_OutsideValue{};
167 };
168 } // end namespace itk
169 
170 #ifndef ITK_MANUAL_INSTANTIATION
171 # include "itkRobustAutomaticThresholdImageFilter.hxx"
172 #endif
173 
174 #endif
itk::RobustAutomaticThresholdCalculator
Compute the robust automatic threshold.
Definition: itkRobustAutomaticThresholdCalculator.h:40
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::RobustAutomaticThresholdImageFilter::GradientImagePointer
typename TGradientImage::Pointer GradientImagePointer
Definition: itkRobustAutomaticThresholdImageFilter.h:79
itk::RobustAutomaticThresholdImageFilter::GradientImageType
TGradientImage GradientImageType
Definition: itkRobustAutomaticThresholdImageFilter.h:69
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:639
itk::RobustAutomaticThresholdImageFilter
Threshold an image using robust automatic threshold selection (RATS) method.
Definition: itkRobustAutomaticThresholdImageFilter.h:50
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::RobustAutomaticThresholdImageFilter::SetGradientImage
void SetGradientImage(GradientImageType *input)
Definition: itkRobustAutomaticThresholdImageFilter.h:123
itk::RobustAutomaticThresholdImageFilter::OutputIndexType
typename TOutputImage::IndexType OutputIndexType
Definition: itkRobustAutomaticThresholdImageFilter.h:85
itk::RobustAutomaticThresholdImageFilter::GradientPixelType
typename TGradientImage::PixelType GradientPixelType
Definition: itkRobustAutomaticThresholdImageFilter.h:74
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::RobustAutomaticThresholdImageFilter::OutputSizeType
typename TOutputImage::SizeType OutputSizeType
Definition: itkRobustAutomaticThresholdImageFilter.h:84
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::RobustAutomaticThresholdImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkRobustAutomaticThresholdImageFilter.h:72
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::RobustAutomaticThresholdImageFilter::SetInput2
void SetInput2(GradientImageType *input)
Definition: itkRobustAutomaticThresholdImageFilter.h:145
itkImageToImageFilter.h
itk::RobustAutomaticThresholdImageFilter::InputIndexType
typename TInputImage::IndexType InputIndexType
Definition: itkRobustAutomaticThresholdImageFilter.h:82
itk::RobustAutomaticThresholdImageFilter::SetInput1
void SetInput1(TInputImage *input)
Definition: itkRobustAutomaticThresholdImageFilter.h:138
itk::Concept::Comparable
Definition: itkConceptChecking.h:332
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::RobustAutomaticThresholdImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkRobustAutomaticThresholdImageFilter.h:73
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itkRobustAutomaticThresholdCalculator.h
itk::RobustAutomaticThresholdImageFilter::GetGradientImage
GradientImageType * GetGradientImage()
Definition: itkRobustAutomaticThresholdImageFilter.h:131
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::RobustAutomaticThresholdImageFilter::InputSizeType
typename TInputImage::SizeType InputSizeType
Definition: itkRobustAutomaticThresholdImageFilter.h:81