OTB  10.0.0
Orfeo Toolbox
otbClampVectorImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbClampVectorImageFilter_h
22 #define otbClampVectorImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 
26 namespace otb
27 {
28 
47 template <class TInputImage, class TOutputImage = TInputImage>
48 class ITK_EXPORT ClampVectorImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
49 {
50 public:
53  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
54  typedef itk::SmartPointer<Self> Pointer;
55  typedef itk::SmartPointer<const Self> ConstPointer;
56 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(ClampVectorImageFilter, itk::ImageToImageFilter);
62 
63 
65  typedef TInputImage InputImageType;
66  typedef typename InputImageType::ConstPointer InputImagePointer;
67  typedef typename InputImageType::RegionType InputImageRegionType;
68  typedef typename InputImageType::PixelType InputImagePixelType;
69  typedef typename InputImageType::InternalPixelType InputImageInternalPixelType;
70 
72  typedef TOutputImage OutputImageType;
73  typedef typename OutputImageType::Pointer OutputImagePointer;
74  typedef typename OutputImageType::RegionType OutputImageRegionType;
75  typedef typename OutputImageType::PixelType OutputImagePixelType;
76  typedef typename OutputImageType::InternalPixelType OutputImageInternalPixelType;
77 
78 
80  void ClampAbove(const OutputImageInternalPixelType& thresh);
81 
83  void ClampBelow(const OutputImageInternalPixelType& thresh);
84 
86  void ClampOutside(const OutputImageInternalPixelType& lower, const OutputImageInternalPixelType& upper);
87 
90  {
91  m_Lower = val;
92  m_DLower = static_cast<double>(val);
93  this->Modified();
94  }
95  itkGetConstMacro(Lower, OutputImageInternalPixelType);
97 
100  {
101  m_Upper = val;
102  m_DUpper = static_cast<double>(val);
103  this->Modified();
104  }
105  itkGetConstMacro(Upper, OutputImageInternalPixelType);
107 
108 
109 protected:
112  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
113 
124  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
125 
126  void GenerateOutputInformation(void) override
127  {
128  Superclass::GenerateOutputInformation();
129 
130  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel());
131  }
132 
133 private:
134  ClampVectorImageFilter(const Self&) = delete;
135  void operator=(const Self&) = delete;
136 
137  double m_DLower;
138  double m_DUpper;
139 
142 };
143 
144 
145 } // end namespace otb
146 
147 #ifndef OTB_MANUAL_INSTANTIATION
149 #endif
150 
151 #endif
Set image values to a user-specified value if they are below, above, or between simple threshold valu...
OutputImageType::RegionType OutputImageRegionType
itk::SmartPointer< const Self > ConstPointer
OutputImageInternalPixelType m_Lower
InputImageType::RegionType InputImageRegionType
OutputImageType::InternalPixelType OutputImageInternalPixelType
OutputImageType::Pointer OutputImagePointer
OutputImageType::PixelType OutputImagePixelType
void operator=(const Self &)=delete
itk::SmartPointer< Self > Pointer
ClampVectorImageFilter(const Self &)=delete
OutputImageInternalPixelType m_Upper
InputImageType::InternalPixelType InputImageInternalPixelType
void GenerateOutputInformation(void) override
InputImageType::ConstPointer InputImagePointer
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
InputImageType::PixelType InputImagePixelType
void SetLower(OutputImageInternalPixelType val)
void SetUpper(OutputImageInternalPixelType val)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.