OTB  6.7.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-2019 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"
30 
31 namespace otb
32 {
33 
50 template<class TInputImage>
51 class ITK_EXPORT PersistentCompareImageFilter :
52  public PersistentImageFilter<TInputImage, TInputImage>
53 {
54 public:
60 
62  itkNewMacro(Self);
63 
66 
68  typedef TInputImage ImageType;
69  typedef typename TInputImage::Pointer InputImagePointer;
70 
71  typedef typename TInputImage::RegionType RegionType;
72  typedef typename TInputImage::SizeType SizeType;
74  typedef typename TInputImage::PixelType PixelType;
76 
77  itkStaticConstMacro(InputImageDimension, unsigned int,
78  TInputImage::ImageDimension);
79 
81  itkStaticConstMacro(ImageDimension, unsigned int,
82  TInputImage::ImageDimension);
83 
86 
89 
93 
95  const TInputImage * GetInput1();
96  const TInputImage * GetInput2();
98 
100  void SetInput1(const TInputImage *image);
101 
103  void SetInput2(const TInputImage *image);
104 
107  {
108  return this->GetPSNROutput()->Get();
109  }
110  RealObjectType* GetPSNROutput();
111  const RealObjectType* GetPSNROutput() const;
113 
115  RealType GetMSE() const
116  {
117  return this->GetMSEOutput()->Get();
118  }
119  RealObjectType* GetMSEOutput();
120  const RealObjectType* GetMSEOutput() const;
122 
124  RealType GetMAE() const
125  {
126  return this->GetMAEOutput()->Get();
127  }
128  RealObjectType* GetMAEOutput();
129  const RealObjectType* GetMAEOutput() const;
131 
134  {
135  return this->GetDiffCountOutput()->Get();
136  }
137  RealObjectType* GetDiffCountOutput();
138  const RealObjectType* GetDiffCountOutput() const;
140 
141  itkGetMacro(PhysicalSpaceCheck,bool);
142  itkSetMacro(PhysicalSpaceCheck,bool);
143 
146  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
147  using Superclass::MakeOutput;
148 
152  void AllocateOutputs() override;
153  void GenerateOutputInformation() override;
154  void Synthetize(void) override;
155  void Reset(void) override;
157 
158 protected:
161  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
162 
164  void ThreadedGenerateData(const RegionType&
165  outputRegionForThread,
166  itk::ThreadIdType threadId) override;
167 
171  void VerifyInputInformation() override;
172 
173 private:
174  PersistentCompareImageFilter(const Self &) = delete;
175  void operator =(const Self&) = delete;
176 
184 }; // end of class PersistentCompareImageFilter
185 
186 /*===========================================================================*/
187 
217 template<class TInputImage>
218 class ITK_EXPORT StreamingCompareImageFilter :
219  public PersistentFilterStreamingDecorator<PersistentCompareImageFilter<TInputImage> >
220 {
221 public:
228 
230  itkNewMacro(Self);
231 
234 
235  typedef typename Superclass::FilterType CompareFilterType;
236  typedef typename CompareFilterType::PixelType PixelType;
238  typedef TInputImage InputImageType;
239 
243 
245  void SetInput1(InputImageType * input)
246  {
247  this->GetFilter()->SetInput1(input);
248  }
249 
251  void SetInput2(InputImageType * input)
252  {
253  this->GetFilter()->SetInput2(input);
254  }
255 
258  {
259  return this->GetFilter()->GetPSNROutput()->Get();
260  }
262  {
263  return this->GetFilter()->GetPSNROutput();
264  }
266  {
267  return this->GetFilter()->GetPSNROutput();
268  }
270 
272  RealType GetMSE() const
273  {
274  return this->GetMSEOutput()->Get();
275  }
277  {
278  return this->GetFilter()->GetMSEOutput();
279  }
281  {
282  return this->GetFilter()->GetMSEOutput();
283  }
285 
287  RealType GetMAE() const
288  {
289  return this->GetFilter()->GetMAEOutput()->Get();
290  }
292  {
293  return this->GetFilter()->GetMAEOutput();
294  }
296  {
297  return this->GetFilter()->GetMAEOutput();
298  }
300 
303  {
304  return this->GetFilter()->GetDiffCountOutput()->Get();
305  }
307  {
308  return this->GetFilter()->GetDiffCountOutput();
309  }
311  {
312  return this->GetFilter()->GetDiffCountOutput();
313  }
315 
317  void SetPhysicalSpaceCheck(bool flag)
318  {
319  this->GetFilter()->SetPhysicalSpaceCheck(flag);
320  }
321 
324  {
325  return this->GetFilter()->GetPhysicalSpaceCheck();
326  }
327 
328 protected:
331 
334 
335 private:
336  StreamingCompareImageFilter(const Self &) = delete;
337  void operator =(const Self&) = delete;
338 };
339 
340 } // end namespace otb
341 
342 #ifndef OTB_MANUAL_INSTANTIATION
344 #endif
345 
346 #endif
const RealObjectType * GetMAEOutput() const
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:137
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
const RealObjectType * GetDiffCountOutput() const
itk::SmartPointer< const Self > ConstPointer
const RealObjectType * GetPSNROutput() const
PersistentImageFilter< TInputImage, TInputImage > Superclass
PersistentFilterStreamingDecorator< PersistentCompareImageFilter< TInputImage > > Superclass
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
itk::SimpleDataObjectDecorator< RealType > RealObjectType
itk::SimpleDataObjectDecorator< PixelType > PixelObjectType
Monteverdi_FLOATING_TYPE RealType
Definition: mvdTypes.h:84
itk::SmartPointer< const Self > ConstPointer
unsigned int ThreadIdType
itk::SimpleDataObjectDecorator< RealType > RealObjectType
This class streams the whole input image through the PersistentCompareImageFilter.
itk::NumericTraits< PixelType >::RealType RealType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Compute mean squared error, mean absolute error and PSNR of two imagee using the output requested reg...
This filter is the base class for all filter persisting data through multiple update. For instance, a filter computing global statistics on an image with streaming capabilities will have to keep the temporary results for each streamed piece of the image in order to synthesize the global statistics at the end. This filter is an itk::ImageToImageFilter, providing two additional methods. The first one, Synthetize(), allows the user to synthesize temporary data produced by the multiple updates on different pieces of the image to the global result. The second one, Reset(), allows the user to reset the temporary data for a new input image for instance.
const RealObjectType * GetMSEOutput() const
This filter link a persistent filter with a StreamingImageVirtualWriter.