OTB  9.0.0
Orfeo Toolbox
otbMatrixImageFilter.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 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 ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) 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
otb::MatrixImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMatrixImageFilter.h:68
otb::MatrixImageFilter::GetMatrix
MatrixType GetMatrix()
Definition: otbMatrixImageFilter.h:101
otb::MatrixImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbMatrixImageFilter.h:89
otb::MatrixImageFilter::InputImageType
TInputImage InputImageType
Definition: otbMatrixImageFilter.h:59
otb::MatrixImageFilter::Superclass
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
Definition: otbMatrixImageFilter.h:66
otb::MatrixImageFilter::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbMatrixImageFilter.h:74
otb::MatrixImageFilter::SetMatrix
void SetMatrix(MatrixType mat)
Definition: otbMatrixImageFilter.h:96
otb::MatrixImageFilter::VectorType
vnl_vector< InputRealType > VectorType
Definition: otbMatrixImageFilter.h:86
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MatrixImageFilter::m_MatrixByVector
bool m_MatrixByVector
Definition: otbMatrixImageFilter.h:143
otb::MatrixImageFilter::SizeType
InputImageType::SizeType SizeType
Definition: otbMatrixImageFilter.h:92
otb::MatrixImageFilter::InputRealType
itk::NumericTraits< InputInternalPixelType >::RealType InputRealType
Definition: otbMatrixImageFilter.h:84
otb::MatrixImageFilter::~MatrixImageFilter
~MatrixImageFilter() override
Definition: otbMatrixImageFilter.h:113
otb::MatrixImageFilter::OutputInternalPixelType
OutputImageType::InternalPixelType OutputInternalPixelType
Definition: otbMatrixImageFilter.h:80
otb::MatrixImageFilter
Apply a matrix multiplication over the channels of an image.
Definition: otbMatrixImageFilter.h:50
otb::MatrixImageFilter::InputInternalPixelType
InputImageType::InternalPixelType InputInternalPixelType
Definition: otbMatrixImageFilter.h:79
otb::MatrixImageFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbMatrixImageFilter.h:78
otb::MatrixImageFilter::m_Matrix
MatrixType m_Matrix
Definition: otbMatrixImageFilter.h:138
otb::MatrixImageFilter::Self
MatrixImageFilter Self
Definition: otbMatrixImageFilter.h:65
otb::MatrixImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMatrixImageFilter.h:67
otb::MatrixImageFilter::MatrixType
TMatrix MatrixType
Definition: otbMatrixImageFilter.h:85
otb::MatrixImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbMatrixImageFilter.h:62
otbMatrixImageFilter.hxx