OTB  9.0.0
Orfeo Toolbox
otbStreamingMatrixTransposeMatrixImageFilter.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 #ifndef otbStreamingMatrixTransposeMatrixImageFilter_h
23 #define otbStreamingMatrixTransposeMatrixImageFilter_h
24 
26 #include "itkSimpleDataObjectDecorator.h"
27 #include "otbStreamingTraits.h"
28 #include "itkVariableSizeMatrix.h"
29 #include "itkVariableLengthVector.h"
31 
32 namespace otb
33 {
34 
54 template <class TInputImage, class TInputImage2>
55 class ITK_EXPORT PersistentMatrixTransposeMatrixImageFilter : public PersistentImageFilter<TInputImage, TInputImage>
56 {
57 public:
61  typedef itk::SmartPointer<Self> Pointer;
62  typedef itk::SmartPointer<const Self> ConstPointer;
63 
65  itkNewMacro(Self);
66 
69 
71  // First Input
72  typedef TInputImage ImageType;
73  typedef typename TInputImage::Pointer InputImagePointer;
74  typedef typename TInputImage::RegionType RegionType;
75  typedef typename TInputImage::SizeType SizeType;
76  typedef typename TInputImage::IndexType IndexType;
77  typedef typename TInputImage::PixelType PixelType;
78  typedef typename TInputImage::InternalPixelType InternalPixelType;
79 
80  typedef typename TInputImage2::IndexType IndexType2;
81  typedef typename TInputImage2::PixelType PixelType2;
82  typedef typename TInputImage2::InternalPixelType InternalPixelType2;
83 
84  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
85 
86  itkSetMacro(UsePadFirstInput, bool);
87  itkGetMacro(UsePadFirstInput, bool);
88  itkSetMacro(UsePadSecondInput, bool);
89  itkGetMacro(UsePadSecondInput, bool);
90 
92  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
93 
95  // First Input
96  typedef double RealType;
97  typedef itk::VariableLengthVector<RealType> RealPixelType;
98 
100  typedef typename itk::DataObject::Pointer DataObjectPointer;
101  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
102 
104  typedef typename itk::Array<long> ArrayLongPixelType;
105  typedef typename itk::VariableSizeMatrix<RealType> MatrixType;
106  typedef typename std::vector<MatrixType> ArrayMatrixType;
107  typedef typename std::vector<RealPixelType> ArrayRealPixelType;
108  typedef typename std::vector<PixelType> ArrayPixelType;
109  typedef itk::SimpleDataObjectDecorator<RealPixelType> RealPixelObjectType;
110  typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType;
111  typedef itk::SimpleDataObjectDecorator<MatrixType> MatrixObjectType;
112 
115  {
116  return this->GetResultOutput()->Get();
117  }
118  MatrixObjectType* GetResultOutput();
119  const MatrixObjectType* GetResultOutput() const;
121 
125  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
126  using Superclass::MakeOutput;
127 
131  void AllocateOutputs() override;
132  void GenerateOutputInformation() override;
133  // Override since the filter needs all the data for the algorithm
134  void GenerateInputRequestedRegion() override;
135  void Reset(void) override;
136  void Synthetize(void) override;
138 
140  void SetFirstInput(const TInputImage* input1)
141  {
142  this->SetInput(0, input1);
143  }
144  void SetSecondInput(const TInputImage2* input2)
145  {
146  this->SetInput(1, input2);
147  }
149 
150  const TInputImage* GetFirstInput()
151  {
152  if (this->GetNumberOfInputs() < 1)
153  {
154  return nullptr;
155  }
156  else
157  return (static_cast<const TInputImage*>(this->itk::ProcessObject::GetInput(0)));
158  }
159 
160  const TInputImage2* GetSecondInput()
161  {
162  if (this->GetNumberOfInputs() < 2)
163  {
164  return nullptr;
165  }
166  else
167  return (static_cast<const TInputImage2*>(this->itk::ProcessObject::GetInput(1)));
168  }
169 
170 protected:
173  {
174  }
175  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
177  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
178 
179 private:
180  PersistentMatrixTransposeMatrixImageFilter(const Self&) = delete;
181  void operator=(const Self&) = delete;
182 
186 
188  unsigned int m_NumberOfComponents1;
189  unsigned int m_NumberOfComponents2;
190 }; // end of class
191 
215 template <class TInputImage1, class TInputImage2>
217  : public PersistentFilterStreamingDecorator<PersistentMatrixTransposeMatrixImageFilter<TInputImage1, TInputImage2>>
218 {
219 public:
223  typedef itk::SmartPointer<Self> Pointer;
224  typedef itk::SmartPointer<const Self> ConstPointer;
225 
227  itkNewMacro(Self);
228 
231 
234  typedef itk::SimpleDataObjectDecorator<MatrixType> MatrixObjectType;
235 
236  typedef TInputImage1 InputImage1Type;
237  typedef TInputImage2 InputImage2Type;
238 
241  {
242  this->GetFilter()->SetFirstInput(input1);
243  }
245  {
246  this->GetFilter()->SetSecondInput(input2);
247  }
248  void SetUsePadFirstInput(bool pad)
249  {
250  this->GetFilter()->SetUsePadFirstInput(pad);
251  }
252  void SetUsePadSecondInput(bool pad)
253  {
254  this->GetFilter()->SetUsePadSecondInput(pad);
255  }
257  {
258  return this->GetFilter()->GetUsePadFirstInput();
259  }
261  {
262  return this->GetFilter()->GetUsePadSecondInput();
263  }
264 
266  MatrixType GetResult(void) const
267  {
268  return this->GetResultOutput()->Get();
269  }
271  {
272  return this->GetFilter()->GetResultOutput();
273  }
275  {
276  return this->GetFilter()->GetResultOutput();
277  }
279 
280 protected:
283 
286  {
287  }
288 
289 private:
290  StreamingMatrixTransposeMatrixImageFilter(const Self&) = delete;
291  void operator=(const Self&) = delete;
292 };
293 
294 } // end namespace otb
295 
296 #ifndef OTB_MANUAL_INSTANTIATION
298 #endif
299 
300 #endif
otb::PersistentMatrixTransposeMatrixImageFilter::m_NumberOfComponents1
unsigned int m_NumberOfComponents1
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:188
otb::PersistentMatrixTransposeMatrixImageFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:100
otb::PersistentMatrixTransposeMatrixImageFilter::IndexType2
TInputImage2::IndexType IndexType2
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:80
otb::StreamingMatrixTransposeMatrixImageFilter
This class streams the whole input image through the PersistentMatrixTransposeMatrixImageFilter.
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:216
otb::PersistentMatrixTransposeMatrixImageFilter::GetResult
MatrixType GetResult() const
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:114
otb::StreamingMatrixTransposeMatrixImageFilter::~StreamingMatrixTransposeMatrixImageFilter
~StreamingMatrixTransposeMatrixImageFilter() override
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:285
otb::PersistentMatrixTransposeMatrixImageFilter::SetSecondInput
void SetSecondInput(const TInputImage2 *input2)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:144
otb::PersistentMatrixTransposeMatrixImageFilter::PixelType2
TInputImage2::PixelType PixelType2
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:81
otb::PersistentMatrixTransposeMatrixImageFilter::SetFirstInput
void SetFirstInput(const TInputImage *input1)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:140
otbPersistentImageFilter.h
otb::PersistentMatrixTransposeMatrixImageFilter::MatrixObjectType
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:111
otb::PersistentMatrixTransposeMatrixImageFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:60
otb::PersistentMatrixTransposeMatrixImageFilter::GetSecondInput
const TInputImage2 * GetSecondInput()
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:160
otb::StreamingMatrixTransposeMatrixImageFilter::SetUsePadFirstInput
void SetUsePadFirstInput(bool pad)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:248
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::StreamingMatrixTransposeMatrixImageFilter::Self
StreamingMatrixTransposeMatrixImageFilter Self
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:221
otb::PersistentMatrixTransposeMatrixImageFilter::m_UsePadSecondInput
bool m_UsePadSecondInput
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:185
otb::StreamingMatrixTransposeMatrixImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentMatrixTransposeMatrixImageFilter< TInputImage1, TInputImage2 > > Superclass
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:222
otb::StreamingMatrixTransposeMatrixImageFilter::GetResult
MatrixType GetResult(void) const
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:266
otbPersistentFilterStreamingDecorator.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PersistentMatrixTransposeMatrixImageFilter::ArrayPixelType
std::vector< PixelType > ArrayPixelType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:108
otb::StreamingMatrixTransposeMatrixImageFilter::GetUsePadSecondInput
bool GetUsePadSecondInput(void)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:260
otb::StreamingMatrixTransposeMatrixImageFilter::GetUsePadFirstInput
bool GetUsePadFirstInput(void)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:256
otb::PersistentMatrixTransposeMatrixImageFilter::ArrayRealPixelType
std::vector< RealPixelType > ArrayRealPixelType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:107
otb::PersistentMatrixTransposeMatrixImageFilter::RealPixelType
itk::VariableLengthVector< RealType > RealPixelType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:97
otb::PersistentMatrixTransposeMatrixImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:61
otb::PersistentMatrixTransposeMatrixImageFilter::RealType
double RealType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:96
otb::StreamingMatrixTransposeMatrixImageFilter::MatrixToTransposeMatrixFilterType
Superclass::FilterType MatrixToTransposeMatrixFilterType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:230
otb::PersistentMatrixTransposeMatrixImageFilter::MatrixType
itk::VariableSizeMatrix< RealType > MatrixType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:105
otb::StreamingMatrixTransposeMatrixImageFilter::MatrixObjectType
itk::SimpleDataObjectDecorator< MatrixType > MatrixObjectType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:234
otb::StreamingMatrixTransposeMatrixImageFilter::GetResultOutput
MatrixObjectType * GetResultOutput(void)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:270
otb::PersistentMatrixTransposeMatrixImageFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:73
otb::PersistentMatrixTransposeMatrixImageFilter::ImageType
TInputImage ImageType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:68
otb::PersistentMatrixTransposeMatrixImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:74
otb::PersistentMatrixTransposeMatrixImageFilter::InternalPixelType2
TInputImage2::InternalPixelType InternalPixelType2
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:82
otb::PersistentMatrixTransposeMatrixImageFilter::InternalPixelType
TInputImage::InternalPixelType InternalPixelType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:78
otb::StreamingMatrixTransposeMatrixImageFilter::InputImage2Type
TInputImage2 InputImage2Type
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:237
otb::PersistentMatrixTransposeMatrixImageFilter::m_NumberOfComponents2
unsigned int m_NumberOfComponents2
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:189
otbStreamingTraits.h
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::PersistentMatrixTransposeMatrixImageFilter
Compute.
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:55
otb::StreamingMatrixTransposeMatrixImageFilter::SetFirstInput
void SetFirstInput(InputImage1Type *input1)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:240
otb::PersistentMatrixTransposeMatrixImageFilter::ArrayMatrixType
std::vector< MatrixType > ArrayMatrixType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:106
otb::StreamingMatrixTransposeMatrixImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:224
otb::StreamingMatrixTransposeMatrixImageFilter::MatrixType
MatrixToTransposeMatrixFilterType::MatrixType MatrixType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:233
otb::PersistentMatrixTransposeMatrixImageFilter::m_UsePadFirstInput
bool m_UsePadFirstInput
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:184
otb::StreamingMatrixTransposeMatrixImageFilter::SetSecondInput
void SetSecondInput(InputImage2Type *input2)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:244
otb::PersistentMatrixTransposeMatrixImageFilter::~PersistentMatrixTransposeMatrixImageFilter
~PersistentMatrixTransposeMatrixImageFilter() override
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:172
otb::PersistentMatrixTransposeMatrixImageFilter::m_ThreadSum
ArrayMatrixType m_ThreadSum
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:183
otb::StreamingMatrixTransposeMatrixImageFilter::GetResultOutput
const MatrixObjectType * GetResultOutput() const
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:274
otb::PersistentMatrixTransposeMatrixImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:76
otb::PersistentMatrixTransposeMatrixImageFilter::Self
PersistentMatrixTransposeMatrixImageFilter Self
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:59
otb::PersistentMatrixTransposeMatrixImageFilter::RealPixelObjectType
itk::SimpleDataObjectDecorator< RealPixelType > RealPixelObjectType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:109
otbStreamingMatrixTransposeMatrixImageFilter.hxx
otb::PersistentMatrixTransposeMatrixImageFilter::PixelObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:110
otb::StreamingMatrixTransposeMatrixImageFilter::InputImage1Type
TInputImage1 InputImage1Type
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:236
otb::PersistentMatrixTransposeMatrixImageFilter::ArrayLongPixelType
itk::Array< long > ArrayLongPixelType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:104
otb::PersistentMatrixTransposeMatrixImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:62
otb::PersistentMatrixTransposeMatrixImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:101
otb::StreamingMatrixTransposeMatrixImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:223
otb::PersistentMatrixTransposeMatrixImageFilter::GetFirstInput
const TInputImage * GetFirstInput()
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:150
otb::StreamingMatrixTransposeMatrixImageFilter::SetUsePadSecondInput
void SetUsePadSecondInput(bool pad)
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:252
otb::PersistentMatrixTransposeMatrixImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:77
otb::StreamingMatrixTransposeMatrixImageFilter::StreamingMatrixTransposeMatrixImageFilter
StreamingMatrixTransposeMatrixImageFilter()
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:282
otb::PersistentMatrixTransposeMatrixImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbStreamingMatrixTransposeMatrixImageFilter.h:75