OTB  9.0.0
Orfeo Toolbox
otbConcatenateScalarValueImageFilter.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 otbConcatenateScalarValueImageFilter_h
22 #define otbConcatenateScalarValueImageFilter_h
23 
24 #include "itkMacro.h"
25 #include "itkUnaryFunctorImageFilter.h"
26 
27 namespace otb
28 {
29 
30 namespace Functor
31 {
32 
40 template <class TInput, class TOutput>
42 {
43 public:
44  typedef TInput InputType;
45  typedef TOutput OutputType;
46 
47  typedef typename InputType::ComponentType ComponentType;
48 
50  {
51  }
53  {
54  }
55 
57  {
58  return m_ScalarValue;
59  }
60 
62  {
63  m_ScalarValue = p;
64  }
65 
66  bool operator!=(const ConcatenateScalarValueFunctor& itkNotUsed(other)) const
67  {
68  return false;
69  }
70 
71  bool operator==(const ConcatenateScalarValueFunctor& other) const
72  {
73  return !(*this != other);
74  }
75 
77  {
78  OutputType out(in.Size() + 1);
79  for (unsigned int j = 0; j < in.Size(); ++j)
80  {
81  out[j] = in[j];
82  }
83  out[in.Size()] = m_ScalarValue;
84  return out;
85  }
86 
87 private:
89 };
90 }
91 
101 template <class TInputImage, class TOutputImage>
103  : public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
104  Functor::ConcatenateScalarValueFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
105 {
106 public:
109  typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
112  typedef itk::SmartPointer<Self> Pointer;
113  typedef itk::SmartPointer<const Self> ConstPointer;
114 
116 
118  itkNewMacro(Self);
119 
121  itkTypeMacro(ConcatenateScalarValueImageFilter, otb::UnaryFunctorImageFilter);
122 
124  typedef typename TInputImage::PixelType InputPixelType;
125  typedef typename InputPixelType::ComponentType InputComponentType;
126  typedef typename TOutputImage::PixelType OutputPixelType;
127 
129  {
130  return this->GetFunctor().GetScalarValue();
131  }
132 
134  {
135  this->GetFunctor().SetScalarValue(p);
136  this->Modified();
137  }
138 
139 protected:
141 
143  {
144  }
145 
146  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
147 
148  void GenerateOutputInformation() override;
149 
150 private:
151  ConcatenateScalarValueImageFilter(const Self&) = delete;
152 
153  void operator=(const Self&) = delete;
154 };
155 
156 } // end namespace otb
157 
158 #ifndef OTB_MANUAL_INSTANTIATION
160 #endif
161 
162 #endif
otb::Functor::ConcatenateScalarValueFunctor::OutputType
TOutput OutputType
Definition: otbConcatenateScalarValueImageFilter.h:45
otb::ConcatenateScalarValueImageFilter
Applies a projective projection to each pixel of an image.
Definition: otbConcatenateScalarValueImageFilter.h:102
otb::ConcatenateScalarValueImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbConcatenateScalarValueImageFilter.h:112
otb::ConcatenateScalarValueImageFilter::~ConcatenateScalarValueImageFilter
~ConcatenateScalarValueImageFilter() override
Definition: otbConcatenateScalarValueImageFilter.h:142
otb::Functor::ConcatenateScalarValueFunctor::InputType
TInput InputType
Definition: otbConcatenateScalarValueImageFilter.h:44
otb::Functor::ConcatenateScalarValueFunctor::GetScalarValue
const ComponentType & GetScalarValue()
Definition: otbConcatenateScalarValueImageFilter.h:56
otb::Functor::ConcatenateScalarValueFunctor::SetScalarValue
void SetScalarValue(const ComponentType &p)
Definition: otbConcatenateScalarValueImageFilter.h:61
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ConcatenateScalarValueImageFilter::InputComponentType
InputPixelType::ComponentType InputComponentType
Definition: otbConcatenateScalarValueImageFilter.h:125
otbConcatenateScalarValueImageFilter.hxx
otb::ConcatenateScalarValueImageFilter::OutputPixelType
TOutputImage::PixelType OutputPixelType
Definition: otbConcatenateScalarValueImageFilter.h:126
otb::ConcatenateScalarValueImageFilter::FunctorType
Functor::ConcatenateScalarValueFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: otbConcatenateScalarValueImageFilter.h:115
otb::ConcatenateScalarValueImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbConcatenateScalarValueImageFilter.h:113
otb::Functor::ConcatenateScalarValueFunctor::operator!=
bool operator!=(const ConcatenateScalarValueFunctor &) const
Definition: otbConcatenateScalarValueImageFilter.h:66
otb::ConcatenateScalarValueImageFilter::GetScalarValue
const InputComponentType & GetScalarValue()
Definition: otbConcatenateScalarValueImageFilter.h:128
otb::Functor::ConcatenateScalarValueFunctor::ComponentType
InputType::ComponentType ComponentType
Definition: otbConcatenateScalarValueImageFilter.h:47
otb::ConcatenateScalarValueImageFilter::Superclass
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::ConcatenateScalarValueFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Definition: otbConcatenateScalarValueImageFilter.h:111
otb::ConcatenateScalarValueImageFilter::InputPixelType
TInputImage::PixelType InputPixelType
Definition: otbConcatenateScalarValueImageFilter.h:121
otb::Functor::ConcatenateScalarValueFunctor
TODO.
Definition: otbConcatenateScalarValueImageFilter.h:41
otb::Functor::ConcatenateScalarValueFunctor::~ConcatenateScalarValueFunctor
virtual ~ConcatenateScalarValueFunctor()
Definition: otbConcatenateScalarValueImageFilter.h:52
otb::Functor::ConcatenateScalarValueFunctor::m_ScalarValue
ComponentType m_ScalarValue
Definition: otbConcatenateScalarValueImageFilter.h:88
otb::Functor::ConcatenateScalarValueFunctor::ConcatenateScalarValueFunctor
ConcatenateScalarValueFunctor()
Definition: otbConcatenateScalarValueImageFilter.h:49
otb::Functor::ConcatenateScalarValueFunctor::operator==
bool operator==(const ConcatenateScalarValueFunctor &other) const
Definition: otbConcatenateScalarValueImageFilter.h:71
otb::ConcatenateScalarValueImageFilter::Self
ConcatenateScalarValueImageFilter Self
Definition: otbConcatenateScalarValueImageFilter.h:108
otb::Functor::ConcatenateScalarValueFunctor::operator()
OutputType operator()(const InputType &in)
Definition: otbConcatenateScalarValueImageFilter.h:76
otb::ConcatenateScalarValueImageFilter::SetScalarValue
void SetScalarValue(const InputComponentType &p)
Definition: otbConcatenateScalarValueImageFilter.h:133