OTB  10.0.0
Orfeo Toolbox
otbBandMathImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbBandMathImageFilter_h
24 #define otbBandMathImageFilter_h
25 
26 #include "itkInPlaceImageFilter.h"
27 #include "itkImageRegionIteratorWithIndex.h"
28 #include "itkArray.h"
29 
30 #include "otbParser.h"
31 #include <string>
32 
33 namespace otb
34 {
82 template <class TImage>
83 class ITK_EXPORT BandMathImageFilter : public itk::InPlaceImageFilter<TImage>
84 {
85 public:
88  typedef itk::InPlaceImageFilter<TImage> Superclass;
89  typedef itk::SmartPointer<Self> Pointer;
90  typedef itk::SmartPointer<const Self> ConstPointer;
91 
93  itkNewMacro(Self);
94 
96  itkTypeMacro(BandMathImageFilter, InPlaceImageFilter);
97 
99  typedef TImage ImageType;
100  typedef typename ImageType::ConstPointer ImagePointer;
101  typedef typename ImageType::RegionType ImageRegionType;
102  typedef typename ImageType::PixelType PixelType;
103  typedef typename ImageType::IndexType IndexType;
104  typedef typename ImageType::PointType OrigineType;
105  typedef typename ImageType::SpacingType SpacingType;
107  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
108 
110  using Superclass::SetNthInput;
111  void SetNthInput(DataObjectPointerArraySizeType idx, const ImageType* image);
112  void SetNthInput(DataObjectPointerArraySizeType idx, const ImageType* image, const std::string& varName);
114 
116  void SetNthInputName(DataObjectPointerArraySizeType idx, const std::string& expression);
117 
119  void SetExpression(const std::string& expression);
120 
122  std::string GetExpression() const;
123 
125  std::string GetNthInputName(DataObjectPointerArraySizeType idx) const;
126 
128  ImageType* GetNthInput(DataObjectPointerArraySizeType idx);
129 
130 protected:
132  ~BandMathImageFilter() override;
133  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
134 
135  void BeforeThreadedGenerateData() override;
136  void ThreadedGenerateData(const ImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
137  void AfterThreadedGenerateData() override;
138 
139 private:
140  BandMathImageFilter(const Self&) = delete;
141  void operator=(const Self&) = delete;
142 
143  std::string m_Expression;
144  std::vector<ParserType::Pointer> m_VParser;
145  std::vector<std::vector<double>> m_AImage;
146  std::vector<std::string> m_VVarName;
147  unsigned int m_NbVar;
148 
151 
154  itk::Array<long> m_ThreadUnderflow;
155  itk::Array<long> m_ThreadOverflow;
156 };
157 
158 } // end namespace otb
159 
160 #ifndef OTB_MANUAL_INSTANTIATION
162 #endif
163 
164 #endif
Performs a mathematical operation on the input images according to the formula specified by the user.
ImageType::IndexType IndexType
ImageType::RegionType ImageRegionType
itk::SmartPointer< Self > Pointer
std::vector< std::vector< double > > m_AImage
BandMathImageFilter(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
ImageType::ConstPointer ImagePointer
ImageType::SpacingType SpacingType
itk::Array< long > m_ThreadUnderflow
itk::InPlaceImageFilter< TImage > Superclass
std::vector< std::string > m_VVarName
ImageType::PointType OrigineType
ImageType::PixelType PixelType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
BandMathImageFilter< TImage > Self
itk::Array< long > m_ThreadOverflow
void operator=(const Self &)=delete
std::vector< ParserType::Pointer > m_VParser
Definition of the standard floating point parser. Standard implementation of the mathematical express...
Definition: otbParser.h:46
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.