OTB  10.0.0
Orfeo Toolbox
otbMatrixImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbMatrixImageFilter_h
22 #define otbMatrixImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbMath.h"
26 
27 namespace otb
28 {
29 
49 template <class TInputImage, class TOutputImage, class TMatrix = vnl_matrix<typename itk::NumericTraits<typename TInputImage::InternalPixelType>::RealType>>
50 class ITK_EXPORT MatrixImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
51 {
52 public:
54  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
55  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
57 
59  typedef TInputImage InputImageType;
60 
62  typedef TOutputImage OutputImageType;
63 
66  typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
67  typedef itk::SmartPointer<Self> Pointer;
68  typedef itk::SmartPointer<const Self> ConstPointer;
69 
71  itkNewMacro(Self);
72 
74  itkTypeMacro(MatrixImageFilter, ImageToImageFilter);
75 
77  typedef typename InputImageType::PixelType InputPixelType;
78  typedef typename OutputImageType::PixelType OutputPixelType;
79  typedef typename InputImageType::InternalPixelType InputInternalPixelType;
80  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
81 
83  // To support complexe...
84  typedef typename itk::NumericTraits<InputInternalPixelType>::RealType InputRealType;
85  typedef TMatrix MatrixType;
86  typedef vnl_vector<InputRealType> VectorType;
87 
89  typedef typename OutputImageType::RegionType OutputImageRegionType;
90 
92  typedef typename InputImageType::SizeType SizeType;
93 
94 
97  {
98  m_Matrix = mat;
99  this->Modified();
100  }
102  {
103  return m_Matrix;
104  }
106 
107  itkGetConstMacro(MatrixByVector, bool);
108  itkSetMacro(MatrixByVector, bool);
109  itkBooleanMacro(MatrixByVector);
110 
111 protected:
114  {
115  }
116  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
117 
121  void GenerateOutputInformation() override;
122 
131  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
132 
133 private:
134  MatrixImageFilter(const Self&) = delete;
135  void operator=(const Self&) = delete;
136 
139 
144 };
145 } // end namespace otb
146 
147 #ifndef OTB_MANUAL_INSTANTIATION
148 #include "otbMatrixImageFilter.hxx"
149 #endif
150 
151 #endif
Apply a matrix multiplication over the channels of an image.
itk::SmartPointer< const Self > ConstPointer
InputImageType::SizeType SizeType
OutputImageType::PixelType OutputPixelType
vnl_vector< InputRealType > VectorType
MatrixImageFilter(const Self &)=delete
void SetMatrix(MatrixType mat)
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
InputImageType::PixelType InputPixelType
void operator=(const Self &)=delete
OutputImageType::InternalPixelType OutputInternalPixelType
OutputImageType::RegionType OutputImageRegionType
itk::NumericTraits< InputInternalPixelType >::RealType InputRealType
InputImageType::InternalPixelType InputInternalPixelType
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.