OTB  7.2.0
Orfeo Toolbox
otbClampImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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 otbClampImageFilter_h
22 #define otbClampImageFilter_h
23 
24 #include "otbConvertTypeFunctor.h"
25 #include "itkUnaryFunctorImageFilter.h"
26 
27 namespace otb
28 {
29 
47 template <class TInputImage, class TOutputImage = TInputImage>
48 class ITK_EXPORT ClampImageFilter
49  : public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
50  Functor::ConvertTypeFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
51 {
52 public:
55  typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
58  typedef itk::SmartPointer<Self> Pointer;
59  typedef itk::SmartPointer<const Self> ConstPointer;
60 
62  itkNewMacro(Self);
63 
65  itkTypeMacro(ClampImageFilter, itk::UnaryFunctorImageFilter);
66 
67 
69  typedef TInputImage InputImageType;
70  typedef typename InputImageType::RegionType InputImageRegionType;
71  typedef typename InputImageType::PixelType InputImagePixelType;
72 
74  typedef TOutputImage OutputImageType;
75  typedef typename OutputImageType::RegionType OutputImageRegionType;
76  typedef typename OutputImageType::PixelType OutputImagePixelType;
77  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
78  typedef typename itk::NumericTraits<OutputInternalPixelType>::ValueType OutputPixelValueType;
79 
80 
82  void ClampAbove(const OutputPixelValueType& thresh);
83 
85  void ClampBelow(const OutputPixelValueType& thresh);
86 
88  void ClampOutside(const OutputPixelValueType& lower, const OutputPixelValueType& upper);
89 
91  void SetLower(OutputPixelValueType val);
92 
93  itkGetConstMacro(Lower, OutputPixelValueType);
94 
96  void SetUpper(OutputPixelValueType val);
97 
98  itkGetConstMacro(Upper, OutputPixelValueType);
99 
100 
101 protected:
103  ~ClampImageFilter() override{};
104  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
105 
106  void GenerateOutputInformation(void) override
107  {
108  Superclass::GenerateOutputInformation();
109  unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel();
110  this->GetFunctor().SetInputComponents(sizeIn);
111  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetFunctor().GetOutputSize());
112  }
113 
114 private:
115  ClampImageFilter(const Self&) = delete;
116  void operator=(const Self&) = delete;
117 
118  OutputPixelValueType m_Lower;
119  OutputPixelValueType m_Upper;
120 };
121 
122 
123 } // end namespace otb
124 
125 #ifndef OTB_MANUAL_INSTANTIATION
126 #include "otbClampImageFilter.hxx"
127 #endif
128 
129 #endif
OutputImageType::PixelType OutputImagePixelType
InputImageType::RegionType InputImageRegionType
Clamp image values to be below, over, or between threhold values.
OutputPixelValueType m_Lower
itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType
OutputImageType::InternalPixelType OutputInternalPixelType
itk::SmartPointer< const Self > ConstPointer
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::ConvertTypeFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
itk::SmartPointer< Self > Pointer
void GenerateOutputInformation(void) override
OutputImageType::RegionType OutputImageRegionType
OutputPixelValueType m_Upper
InputImageType::PixelType InputImagePixelType