OTB  6.7.0
Orfeo Toolbox
otbClampImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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"
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 ,
51  typename TOutputImage::PixelType> >
52 {
53 public:
56  typedef itk::UnaryFunctorImageFilter< TInputImage , TOutputImage ,
57  Functor::ConvertTypeFunctor <typename TInputImage::PixelType ,
58  typename TOutputImage::PixelType> > Superclass;
61 
63  itkNewMacro( Self );
64 
67 
68 
70  typedef TInputImage InputImageType;
71  typedef typename InputImageType::RegionType InputImageRegionType;
72  typedef typename InputImageType::PixelType InputImagePixelType;
73 
75  typedef TOutputImage OutputImageType;
76  typedef typename OutputImageType::RegionType OutputImageRegionType;
77  typedef typename OutputImageType::PixelType OutputImagePixelType;
78  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
80 
81 
83  void ClampAbove(const OutputPixelValueType &thresh);
84 
86  void ClampBelow(const OutputPixelValueType &thresh);
87 
89  void ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper);
90 
92  void SetLower(OutputPixelValueType val);
93 
94  itkGetConstMacro(Lower, OutputPixelValueType);
95 
97  void SetUpper(OutputPixelValueType val);
98 
99  itkGetConstMacro(Upper, OutputPixelValueType);
100 
101 
102 protected:
104  ~ClampImageFilter() override {};
105  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
106 
107  void GenerateOutputInformation(void) override
108  {
109  Superclass::GenerateOutputInformation();
110  unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel();
111  this->GetFunctor().SetInputComponents( sizeIn );
112  this->GetOutput()->SetNumberOfComponentsPerPixel(
113  this->GetFunctor().GetOutputSize () );
114  }
115 
116 private:
117  ClampImageFilter(const Self&) = delete ;
118  void operator=(const Self&) = delete ;
119 
122 };
123 
124 
125 } // end namespace otb
126 
127 #ifndef OTB_MANUAL_INSTANTIATION
128 #include "otbClampImageFilter.hxx"
129 #endif
130 
131 #endif
OutputImageType::PixelType OutputImagePixelType
InputImageType::RegionType InputImageRegionType
Clamp image values to be below, over, or between threhold values.
OutputPixelValueType m_Lower
OutputImageType::InternalPixelType OutputInternalPixelType
itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType
itk::SmartPointer< const Self > ConstPointer
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::ConvertTypeFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
itk::SmartPointer< Self > Pointer
void GenerateOutputInformation(void) override
OutputImageType::RegionType OutputImageRegionType
OutputPixelValueType m_Upper
InputImageType::PixelType InputImagePixelType