OTB  10.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-2024 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() const override;
169 
170 private:
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 
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:
334  void operator=(const Self&) = delete;
335 };
336 
337 } // end namespace otb
338 
339 #ifndef OTB_MANUAL_INSTANTIATION
341 #endif
342 
343 #endif
Compute mean squared error, mean absolute error and PSNR of two imagee using the output requested reg...
itk::SmartPointer< const Self > ConstPointer
void operator=(const Self &)=delete
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
PersistentImageFilter< TInputImage, TInputImage > Superclass
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
itk::NumericTraits< PixelType >::RealType RealType
PersistentCompareImageFilter(const Self &)=delete
itk::SimpleDataObjectDecorator< RealType > RealObjectType
This filter link a persistent filter with a StreamingImageVirtualWriter.
This filter is the base class for all filter persisting data through multiple update....
This class streams the whole input image through the PersistentCompareImageFilter.
void operator=(const Self &)=delete
PersistentFilterStreamingDecorator< PersistentCompareImageFilter< TInputImage > > Superclass
StreamingCompareImageFilter(const Self &)=delete
const RealObjectType * GetMAEOutput() const
itk::SimpleDataObjectDecorator< RealType > RealObjectType
const RealObjectType * GetPSNROutput() const
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
const RealObjectType * GetMSEOutput() const
const RealObjectType * GetDiffCountOutput() const
itk::SmartPointer< const Self > ConstPointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.