OTB  6.7.0
Orfeo Toolbox
otbMultiplyByScalarImageFilter.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 otbMultiplyByScalarImageFilter_h
22 #define otbMultiplyByScalarImageFilter_h
23 
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  }
46  virtual ~MultiplyByScalar() {}
47  inline TOutput operator ()(const TInput& value)
48  {
49  TOutput result;
50 
51  result = static_cast<TOutput>(m_Coef * value);
52 
53  return result;
54  }
55 
56  void SetCoef(double Coef)
57  {
58  m_Coef = Coef;
59  }
60  double GetCoef(void) const
61  {
62  return (m_Coef);
63  }
64 
65 private:
66  double m_Coef;
67 };
68 }
69 
70 template <class TInputImage, class TOutputImage>
71 class ITK_EXPORT MultiplyByScalarImageFilter :
73  TInputImage, TOutputImage,
74  Functor::MultiplyByScalar<
75  typename TInputImage::PixelType,
76  typename TOutputImage::PixelType> >
77 {
78 public:
81  typedef typename itk::UnaryFunctorImageFilter<
82  TInputImage,
83  TOutputImage,
85  typename TInputImage::PixelType,
86  typename TOutputImage::PixelType> > Superclass;
89 
91  itkNewMacro(Self);
92 
93  void SetCoef(double Coef)
94  {
95  this->GetFunctor().SetCoef(Coef);
96  this->Modified();
97  }
98  double GetCoef(void) const
99  {
100  return (this->GetFunctor().GetCoef());
101  }
102 protected:
105 
106 private:
107  MultiplyByScalarImageFilter(const Self &) = delete;
108  void operator =(const Self&) = delete;
109 
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