OTB  9.0.0
Orfeo Toolbox
otbMultiplyByScalarImageFilter.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 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
otb::MultiplyByScalarImageFilter::MultiplyByScalarImageFilter
MultiplyByScalarImageFilter()
Definition: otbMultiplyByScalarImageFilter.h:100
otb::Functor::MultiplyByScalar::GetCoef
double GetCoef(void) const
Definition: otbMultiplyByScalarImageFilter.h:62
otb::MultiplyByScalarImageFilter::SetCoef
void SetCoef(double Coef)
Definition: otbMultiplyByScalarImageFilter.h:89
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MultiplyByScalarImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMultiplyByScalarImageFilter.h:84
otb::MultiplyByScalarImageFilter::Superclass
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::MultiplyByScalar< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Definition: otbMultiplyByScalarImageFilter.h:82
otb::MultiplyByScalarImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMultiplyByScalarImageFilter.h:83
otb::Functor::MultiplyByScalar::operator()
TOutput operator()(const TInput &value)
Definition: otbMultiplyByScalarImageFilter.h:49
otb::Functor::MultiplyByScalar
Definition: otbMultiplyByScalarImageFilter.h:39
otb::Functor::MultiplyByScalar::m_Coef
double m_Coef
Definition: otbMultiplyByScalarImageFilter.h:68
otb::MultiplyByScalarImageFilter
TODO.
Definition: otbMultiplyByScalarImageFilter.h:73
otb::Functor::MultiplyByScalar::MultiplyByScalar
MultiplyByScalar()
Definition: otbMultiplyByScalarImageFilter.h:42
otb::MultiplyByScalarImageFilter::~MultiplyByScalarImageFilter
~MultiplyByScalarImageFilter() override
Definition: otbMultiplyByScalarImageFilter.h:103
otb::Functor::MultiplyByScalar::~MultiplyByScalar
virtual ~MultiplyByScalar()
Definition: otbMultiplyByScalarImageFilter.h:46
otb::MultiplyByScalarImageFilter::GetCoef
double GetCoef(void) const
Definition: otbMultiplyByScalarImageFilter.h:94
otb::Functor::MultiplyByScalar::SetCoef
void SetCoef(double Coef)
Definition: otbMultiplyByScalarImageFilter.h:58
otb::MultiplyByScalarImageFilter::Self
MultiplyByScalarImageFilter Self
Definition: otbMultiplyByScalarImageFilter.h:79