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