OTB  9.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-2022 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
otb::BandMathImageFilter::m_VVarName
std::vector< std::string > m_VVarName
Definition: otbBandMathImageFilter.h:146
otbBandMathImageFilter.hxx
otb::BandMathImageFilter::IndexType
ImageType::IndexType IndexType
Definition: otbBandMathImageFilter.h:103
otb::BandMathImageFilter::m_AImage
std::vector< std::vector< double > > m_AImage
Definition: otbBandMathImageFilter.h:145
otb::BandMathImageFilter::ParserType
Parser ParserType
Definition: otbBandMathImageFilter.h:106
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BandMathImageFilter::m_ThreadUnderflow
itk::Array< long > m_ThreadUnderflow
Definition: otbBandMathImageFilter.h:154
otb::BandMathImageFilter::ImageRegionType
ImageType::RegionType ImageRegionType
Definition: otbBandMathImageFilter.h:101
otb::BandMathImageFilter::SpacingType
ImageType::SpacingType SpacingType
Definition: otbBandMathImageFilter.h:105
otb::BandMathImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBandMathImageFilter.h:90
otb::BandMathImageFilter::m_Origin
OrigineType m_Origin
Definition: otbBandMathImageFilter.h:150
otb::BandMathImageFilter::m_ThreadOverflow
itk::Array< long > m_ThreadOverflow
Definition: otbBandMathImageFilter.h:155
otb::BandMathImageFilter::m_UnderflowCount
long m_UnderflowCount
Definition: otbBandMathImageFilter.h:152
otb::BandMathImageFilter::m_Expression
std::string m_Expression
Definition: otbBandMathImageFilter.h:143
otb::BandMathImageFilter::m_OverflowCount
long m_OverflowCount
Definition: otbBandMathImageFilter.h:153
otb::BandMathImageFilter::Self
BandMathImageFilter< TImage > Self
Definition: otbBandMathImageFilter.h:87
otb::BandMathImageFilter::PixelType
ImageType::PixelType PixelType
Definition: otbBandMathImageFilter.h:102
otb::BandMathImageFilter::m_NbVar
unsigned int m_NbVar
Definition: otbBandMathImageFilter.h:147
otb::BandMathImageFilter::OrigineType
ImageType::PointType OrigineType
Definition: otbBandMathImageFilter.h:104
otb::BandMathImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbBandMathImageFilter.h:107
otb::BandMathImageFilter::ImageType
TImage ImageType
Definition: otbBandMathImageFilter.h:96
otb::BandMathImageFilter::m_VParser
std::vector< ParserType::Pointer > m_VParser
Definition: otbBandMathImageFilter.h:144
otbParser.h
otb::BandMathImageFilter::ImagePointer
ImageType::ConstPointer ImagePointer
Definition: otbBandMathImageFilter.h:100
otb::BandMathImageFilter::m_Spacing
SpacingType m_Spacing
Definition: otbBandMathImageFilter.h:149
otb::Parser
Definition of the standard floating point parser. Standard implementation of the mathematical express...
Definition: otbParser.h:44
otb::BandMathImageFilter::Superclass
itk::InPlaceImageFilter< TImage > Superclass
Definition: otbBandMathImageFilter.h:88
otb::BandMathImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBandMathImageFilter.h:89
otb::BandMathImageFilter
Performs a mathematical operation on the input images according to the formula specified by the user.
Definition: otbBandMathImageFilter.h:83