OTB  9.0.0
Orfeo Toolbox
otbStreamingCompareImageFilter.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 otbStreamingCompareImageFilter_h
23 #define otbStreamingCompareImageFilter_h
24 
26 #include "itkNumericTraits.h"
27 #include "itkArray.h"
28 #include "itkSimpleDataObjectDecorator.h"
30 
31 namespace otb
32 {
33 
50 template <class TInputImage>
51 class ITK_EXPORT PersistentCompareImageFilter : public PersistentImageFilter<TInputImage, TInputImage>
52 {
53 public:
57  typedef itk::SmartPointer<Self> Pointer;
58  typedef itk::SmartPointer<const Self> ConstPointer;
59 
61  itkNewMacro(Self);
62 
65 
67  typedef TInputImage ImageType;
68  typedef typename TInputImage::Pointer InputImagePointer;
69 
70  typedef typename TInputImage::RegionType RegionType;
71  typedef typename TInputImage::SizeType SizeType;
72  typedef typename TInputImage::IndexType IndexType;
73  typedef typename TInputImage::PixelType PixelType;
74  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
75 
76  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
77 
79  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
80 
82  typedef typename itk::NumericTraits<PixelType>::RealType RealType;
83 
85  typedef typename itk::DataObject::Pointer DataObjectPointer;
86 
88  typedef itk::SimpleDataObjectDecorator<RealType> RealObjectType;
89  typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType;
90 
92  const TInputImage* GetInput1();
93  const TInputImage* GetInput2();
95 
97  void SetInput1(const TInputImage* image);
98 
100  void SetInput2(const TInputImage* image);
101 
104  {
105  return this->GetPSNROutput()->Get();
106  }
107  RealObjectType* GetPSNROutput();
108  const RealObjectType* GetPSNROutput() const;
110 
112  RealType GetMSE() const
113  {
114  return this->GetMSEOutput()->Get();
115  }
116  RealObjectType* GetMSEOutput();
117  const RealObjectType* GetMSEOutput() const;
119 
121  RealType GetMAE() const
122  {
123  return this->GetMAEOutput()->Get();
124  }
125  RealObjectType* GetMAEOutput();
126  const RealObjectType* GetMAEOutput() const;
128 
131  {
132  return this->GetDiffCountOutput()->Get();
133  }
134  RealObjectType* GetDiffCountOutput();
135  const RealObjectType* GetDiffCountOutput() const;
137 
138  itkGetMacro(PhysicalSpaceCheck, bool);
139  itkSetMacro(PhysicalSpaceCheck, bool);
140 
143  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
144  using Superclass::MakeOutput;
145 
149  void AllocateOutputs() override;
150  void GenerateOutputInformation() override;
151  void Synthetize(void) override;
152  void Reset(void) override;
154 
155 protected:
158  {
159  }
160  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
161 
163  void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
164 
168  void VerifyInputInformation() override;
169 
170 private:
171  PersistentCompareImageFilter(const Self&) = delete;
172  void operator=(const Self&) = delete;
173 
174  itk::Array<RealType> m_SquareOfDifferences;
175  itk::Array<RealType> m_AbsoluteValueOfDifferences;
176  itk::Array<PixelType> m_ThreadMinRef;
177  itk::Array<PixelType> m_ThreadMaxRef;
178  itk::Array<long> m_Count;
179  itk::Array<long> m_DiffCount;
181 }; // end of class PersistentCompareImageFilter
182 
183 /*===========================================================================*/
184 
214 template <class TInputImage>
215 class ITK_EXPORT StreamingCompareImageFilter : public PersistentFilterStreamingDecorator<PersistentCompareImageFilter<TInputImage>>
216 {
217 public:
221  typedef itk::SmartPointer<Self> Pointer;
222  typedef itk::SmartPointer<const Self> ConstPointer;
223 
225  itkNewMacro(Self);
226 
229 
230  typedef typename Superclass::FilterType CompareFilterType;
233  typedef TInputImage InputImageType;
234 
236  typedef itk::SimpleDataObjectDecorator<RealType> RealObjectType;
237  typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType;
238 
241  {
242  this->GetFilter()->SetInput1(input);
243  }
244 
247  {
248  this->GetFilter()->SetInput2(input);
249  }
250 
253  {
254  return this->GetFilter()->GetPSNROutput()->Get();
255  }
257  {
258  return this->GetFilter()->GetPSNROutput();
259  }
261  {
262  return this->GetFilter()->GetPSNROutput();
263  }
265 
267  RealType GetMSE() const
268  {
269  return this->GetMSEOutput()->Get();
270  }
272  {
273  return this->GetFilter()->GetMSEOutput();
274  }
276  {
277  return this->GetFilter()->GetMSEOutput();
278  }
280 
282  RealType GetMAE() const
283  {
284  return this->GetFilter()->GetMAEOutput()->Get();
285  }
287  {
288  return this->GetFilter()->GetMAEOutput();
289  }
291  {
292  return this->GetFilter()->GetMAEOutput();
293  }
295 
298  {
299  return this->GetFilter()->GetDiffCountOutput()->Get();
300  }
302  {
303  return this->GetFilter()->GetDiffCountOutput();
304  }
306  {
307  return this->GetFilter()->GetDiffCountOutput();
308  }
310 
312  void SetPhysicalSpaceCheck(bool flag)
313  {
314  this->GetFilter()->SetPhysicalSpaceCheck(flag);
315  }
316 
319  {
320  return this->GetFilter()->GetPhysicalSpaceCheck();
321  }
322 
323 protected:
326 
329  {
330  }
331 
332 private:
333  StreamingCompareImageFilter(const Self&) = delete;
334  void operator=(const Self&) = delete;
335 };
336 
337 } // end namespace otb
338 
339 #ifndef OTB_MANUAL_INSTANTIATION
341 #endif
342 
343 #endif
otb::StreamingCompareImageFilter::RealObjectType
itk::SimpleDataObjectDecorator< RealType > RealObjectType
Definition: otbStreamingCompareImageFilter.h:236
otb::PersistentCompareImageFilter::m_AbsoluteValueOfDifferences
itk::Array< RealType > m_AbsoluteValueOfDifferences
Definition: otbStreamingCompareImageFilter.h:175
otb::PersistentCompareImageFilter::GetDiffCount
RealType GetDiffCount() const
Definition: otbStreamingCompareImageFilter.h:130
otb::StreamingCompareImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingCompareImageFilter.h:222
otb::StreamingCompareImageFilter::PixelObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: otbStreamingCompareImageFilter.h:237
otb::StreamingCompareImageFilter::SetInput1
void SetInput1(InputImageType *input)
Definition: otbStreamingCompareImageFilter.h:240
otb::StreamingCompareImageFilter::RealType
CompareFilterType::RealType RealType
Definition: otbStreamingCompareImageFilter.h:232
otb::StreamingCompareImageFilter::SetInput2
void SetInput2(InputImageType *input)
Definition: otbStreamingCompareImageFilter.h:246
otbPersistentImageFilter.h
otb::StreamingCompareImageFilter::Superclass
PersistentFilterStreamingDecorator< PersistentCompareImageFilter< TInputImage > > Superclass
Definition: otbStreamingCompareImageFilter.h:220
otb::StreamingCompareImageFilter::GetPSNROutput
RealObjectType * GetPSNROutput()
Definition: otbStreamingCompareImageFilter.h:256
otb::StreamingCompareImageFilter::GetMSE
RealType GetMSE() const
Definition: otbStreamingCompareImageFilter.h:267
otb::StreamingCompareImageFilter::GetMAEOutput
RealObjectType * GetMAEOutput()
Definition: otbStreamingCompareImageFilter.h:286
otb::PersistentCompareImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbStreamingCompareImageFilter.h:72
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::StreamingCompareImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingCompareImageFilter.h:221
otbPersistentFilterStreamingDecorator.h
otb::PersistentCompareImageFilter::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbStreamingCompareImageFilter.h:85
otb::PersistentCompareImageFilter::m_DiffCount
itk::Array< long > m_DiffCount
Definition: otbStreamingCompareImageFilter.h:179
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::StreamingCompareImageFilter::GetPSNR
RealType GetPSNR() const
Definition: otbStreamingCompareImageFilter.h:252
otb::StreamingCompareImageFilter::GetDiffCountOutput
RealObjectType * GetDiffCountOutput()
Definition: otbStreamingCompareImageFilter.h:301
otb::StreamingCompareImageFilter::SetPhysicalSpaceCheck
void SetPhysicalSpaceCheck(bool flag)
Definition: otbStreamingCompareImageFilter.h:312
otb::StreamingCompareImageFilter::StreamingCompareImageFilter
StreamingCompareImageFilter()
Definition: otbStreamingCompareImageFilter.h:325
otb::StreamingCompareImageFilter::PixelType
CompareFilterType::PixelType PixelType
Definition: otbStreamingCompareImageFilter.h:231
otb::PersistentCompareImageFilter::m_ThreadMaxRef
itk::Array< PixelType > m_ThreadMaxRef
Definition: otbStreamingCompareImageFilter.h:177
otb::PersistentCompareImageFilter::ImageType
TInputImage ImageType
Definition: otbStreamingCompareImageFilter.h:64
otb::PersistentCompareImageFilter::PixelObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: otbStreamingCompareImageFilter.h:89
otb::PersistentCompareImageFilter::Superclass
PersistentImageFilter< TInputImage, TInputImage > Superclass
Definition: otbStreamingCompareImageFilter.h:56
otb::PersistentCompareImageFilter::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbStreamingCompareImageFilter.h:74
otb::StreamingCompareImageFilter::GetPhysicalSpaceCheck
bool GetPhysicalSpaceCheck()
Definition: otbStreamingCompareImageFilter.h:318
otb::PersistentCompareImageFilter::m_SquareOfDifferences
itk::Array< RealType > m_SquareOfDifferences
Definition: otbStreamingCompareImageFilter.h:174
otb::PersistentCompareImageFilter::InputImagePointer
TInputImage::Pointer InputImagePointer
Definition: otbStreamingCompareImageFilter.h:68
otb::StreamingCompareImageFilter::CompareFilterType
Superclass::FilterType CompareFilterType
Definition: otbStreamingCompareImageFilter.h:228
otb::StreamingCompareImageFilter::GetMSEOutput
const RealObjectType * GetMSEOutput() const
Definition: otbStreamingCompareImageFilter.h:275
otb::PersistentCompareImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: otbStreamingCompareImageFilter.h:70
otb::PersistentCompareImageFilter::Self
PersistentCompareImageFilter Self
Definition: otbStreamingCompareImageFilter.h:55
otb::PersistentCompareImageFilter::m_PhysicalSpaceCheck
bool m_PhysicalSpaceCheck
Definition: otbStreamingCompareImageFilter.h:180
otb::StreamingCompareImageFilter::GetMSEOutput
RealObjectType * GetMSEOutput()
Definition: otbStreamingCompareImageFilter.h:271
otb::StreamingCompareImageFilter::GetDiffCount
RealType GetDiffCount() const
Definition: otbStreamingCompareImageFilter.h:297
otb::StreamingCompareImageFilter
This class streams the whole input image through the PersistentCompareImageFilter.
Definition: otbStreamingCompareImageFilter.h:215
otb::PersistentCompareImageFilter::RealObjectType
itk::SimpleDataObjectDecorator< RealType > RealObjectType
Definition: otbStreamingCompareImageFilter.h:88
otb::PersistentCompareImageFilter::GetMAE
RealType GetMAE() const
Definition: otbStreamingCompareImageFilter.h:121
otb::PersistentCompareImageFilter::m_Count
itk::Array< long > m_Count
Definition: otbStreamingCompareImageFilter.h:178
otb::PersistentCompareImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: otbStreamingCompareImageFilter.h:73
otb::StreamingCompareImageFilter::Self
StreamingCompareImageFilter Self
Definition: otbStreamingCompareImageFilter.h:219
otb::PersistentCompareImageFilter::RealType
itk::NumericTraits< PixelType >::RealType RealType
Definition: otbStreamingCompareImageFilter.h:82
otb::PersistentCompareImageFilter::~PersistentCompareImageFilter
~PersistentCompareImageFilter() override
Definition: otbStreamingCompareImageFilter.h:157
otb::PersistentCompareImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingCompareImageFilter.h:57
otb::StreamingCompareImageFilter::InputImageType
TInputImage InputImageType
Definition: otbStreamingCompareImageFilter.h:233
otb::PersistentFilterStreamingDecorator
This filter link a persistent filter with a StreamingImageVirtualWriter.
Definition: otbPersistentFilterStreamingDecorator.h:47
otb::StreamingCompareImageFilter::GetMAEOutput
const RealObjectType * GetMAEOutput() const
Definition: otbStreamingCompareImageFilter.h:290
otb::PersistentCompareImageFilter::m_ThreadMinRef
itk::Array< PixelType > m_ThreadMinRef
Definition: otbStreamingCompareImageFilter.h:176
otb::PersistentCompareImageFilter::GetMSE
RealType GetMSE() const
Definition: otbStreamingCompareImageFilter.h:112
otbStreamingCompareImageFilter.hxx
otb::StreamingCompareImageFilter::GetMAE
RealType GetMAE() const
Definition: otbStreamingCompareImageFilter.h:282
otb::StreamingCompareImageFilter::~StreamingCompareImageFilter
~StreamingCompareImageFilter() override
Definition: otbStreamingCompareImageFilter.h:328
otb::StreamingCompareImageFilter::GetPSNROutput
const RealObjectType * GetPSNROutput() const
Definition: otbStreamingCompareImageFilter.h:260
otb::PersistentCompareImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbStreamingCompareImageFilter.h:71
otb::PersistentCompareImageFilter
Compute mean squared error, mean absolute error and PSNR of two imagee using the output requested reg...
Definition: otbStreamingCompareImageFilter.h:51
otb::PersistentCompareImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStreamingCompareImageFilter.h:58
otb::PersistentCompareImageFilter::GetPSNR
RealType GetPSNR() const
Definition: otbStreamingCompareImageFilter.h:103
otb::StreamingCompareImageFilter::GetDiffCountOutput
const RealObjectType * GetDiffCountOutput() const
Definition: otbStreamingCompareImageFilter.h:305