OTB  7.2.0
Orfeo Toolbox
otbMultiplyByScalarImageFilter.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 otbMultiplyByScalarImageFilter_h
22 #define otbMultiplyByScalarImageFilter_h
23 
24 #include "itkUnaryFunctorImageFilter.h"
25 
26 namespace otb
27 {
28 
35 namespace Functor
36 {
37 
38 template <class TInput, class TOutput>
40 {
41 public:
43  {
44  m_Coef = 1.0;
45  }
47  {
48  }
49  inline TOutput operator()(const TInput& value)
50  {
51  TOutput result;
52 
53  result = static_cast<TOutput>(m_Coef * value);
54 
55  return result;
56  }
57 
58  void SetCoef(double Coef)
59  {
60  m_Coef = Coef;
61  }
62  double GetCoef(void) const
63  {
64  return (m_Coef);
65  }
66 
67 private:
68  double m_Coef;
69 };
70 }
71 
72 template <class TInputImage, class TOutputImage>
74  : public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
75  Functor::MultiplyByScalar<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
76 {
77 public:
80  typedef typename itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
83  typedef itk::SmartPointer<Self> Pointer;
84  typedef itk::SmartPointer<const Self> ConstPointer;
85 
87  itkNewMacro(Self);
88 
89  void SetCoef(double Coef)
90  {
91  this->GetFunctor().SetCoef(Coef);
92  this->Modified();
93  }
94  double GetCoef(void) const
95  {
96  return (this->GetFunctor().GetCoef());
97  }
98 
99 protected:
101  {
102  }
104  {
105  }
106 
107 private:
108  MultiplyByScalarImageFilter(const Self&) = delete;
109  void operator=(const Self&) = delete;
110 };
111 
112 } // end namespace otb
113 
114 #endif
itk::SmartPointer< const Self > ConstPointer
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::MultiplyByScalar< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
static constexpr GLenum value() noexcept