OTB  9.0.0
Orfeo Toolbox
otbClampImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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::ImageToImageFilter<TInputImage, TOutputImage>
50 {
51 public:
54  using Superclass = itk::ImageToImageFilter<TInputImage, TOutputImage>;
56  using Pointer = itk::SmartPointer<Self>;
57  using ConstPointer = itk::SmartPointer<const Self>;
58 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(ClampImageFilter, OSEF);
64 
65 
67  using InputImageType = TInputImage;
68  using InputImageRegionType = typename InputImageType::RegionType;
69  using InputImagePixelType = typename InputImageType::PixelType;
70 
72  using OutputImageType = TOutputImage;
73  using OutputImageRegionType = typename OutputImageType::RegionType;
74  using OutputImagePixelType = typename OutputImageType::PixelType;
75  using OutputInternalPixelType = typename OutputImageType::InternalPixelType;
76  using OutputPixelValueType = typename itk::NumericTraits<OutputInternalPixelType>::ValueType;
77 
79  void ClampAbove(const OutputPixelValueType& thresh);
80 
82  void ClampBelow(const OutputPixelValueType& thresh);
83 
85  void ClampOutside(const OutputPixelValueType& lower, const OutputPixelValueType& upper);
86 
88  void SetThresholds(OutputPixelValueType lowerVal, OutputPixelValueType upperVal);
89  itkGetConstMacro(Lower, OutputPixelValueType);
90  itkGetConstMacro(Upper, OutputPixelValueType);
92 
93 
94 protected:
96  ~ClampImageFilter() override = default;
97  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
98 
99  void GenerateOutputInformation(void) override
100  {
101  Superclass::GenerateOutputInformation();
102  unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel();
103  this->GetFunctor().SetInputComponents(sizeIn);
104  this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetFunctor().GetOutputSize());
105  }
106 
107  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
108 
109  FunctorType & GetFunctor() noexcept { return m_Functor; }
110  FunctorType const& GetFunctor() const noexcept { return m_Functor; }
111 
112 private:
113  ClampImageFilter(const Self&) = delete;
114  void operator=(const Self&) = delete;
115 
119 };
120 
121 
122 } // end namespace otb
123 
124 #ifndef OTB_MANUAL_INSTANTIATION
125 #include "otbClampImageFilter.hxx"
126 #endif
127 
128 #endif
otbConvertTypeFunctor.h
otb::ClampImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: otbClampImageFilter.h:73
otb::ClampImageFilter::m_Upper
OutputPixelValueType m_Upper
Definition: otbClampImageFilter.h:117
otb::ClampImageFilter::OutputPixelValueType
typename itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType
Definition: otbClampImageFilter.h:76
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ClampImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbClampImageFilter.h:56
otb::ClampImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: otbClampImageFilter.h:68
otb::ClampImageFilter::GetFunctor
FunctorType const & GetFunctor() const noexcept
Definition: otbClampImageFilter.h:110
otb::ClampImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbClampImageFilter.h:72
otb::ClampImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbClampImageFilter.h:54
otb::ClampImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: otbClampImageFilter.h:69
otb::ClampImageFilter::m_Functor
FunctorType m_Functor
Definition: otbClampImageFilter.h:118
otb::ClampImageFilter::m_Lower
OutputPixelValueType m_Lower
Definition: otbClampImageFilter.h:116
otbClampImageFilter.hxx
otb::ClampImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbClampImageFilter.h:57
otb::Functor::ConvertTypeFunctor
Definition: otbConvertTypeFunctor.h:40
otb::ClampImageFilter::GenerateOutputInformation
void GenerateOutputInformation(void) override
Definition: otbClampImageFilter.h:99
otb::ClampImageFilter::GetFunctor
FunctorType & GetFunctor() noexcept
Definition: otbClampImageFilter.h:109
otb::ClampImageFilter::OutputInternalPixelType
typename OutputImageType::InternalPixelType OutputInternalPixelType
Definition: otbClampImageFilter.h:75
otb::ClampImageFilter
Clamp image values to be below, over, or between threshold values.
Definition: otbClampImageFilter.h:48
otb::ClampImageFilter::InputImageType
TInputImage InputImageType
Definition: otbClampImageFilter.h:67
otb::ClampImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: otbClampImageFilter.h:74