OTB  9.0.0
Orfeo Toolbox
otbDifferenceImageFilter.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 otbDifferenceImageFilter_h
22 #define otbDifferenceImageFilter_h
23 
25 #include "itkNumericTraits.h"
26 #include "itkArray.h"
27 
28 namespace otb
29 {
30 
44 template <class TInputImage, class TOutputImage>
45 class ITK_EXPORT DifferenceImageFilter : public otb::PersistentImageFilter <TInputImage, TOutputImage>
46 {
47 public:
50  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
51  typedef itk::SmartPointer<Self> Pointer;
52  typedef itk::SmartPointer<const Self> ConstPointer;
53 
55  itkNewMacro(Self);
56 
58  itkTypeMacro(DifferenceImageFilter, ImageToImageFilter);
59 
61  typedef TInputImage InputImageType;
62  typedef TOutputImage OutputImageType;
63  typedef typename OutputImageType::PixelType OutputPixelType;
64  typedef typename OutputImageType::RegionType OutputImageRegionType;
65  typedef typename itk::NumericTraits<OutputPixelType>::RealType RealType;
66  typedef typename itk::NumericTraits<RealType>::AccumulateType AccumulateType;
67  typedef typename itk::NumericTraits<OutputPixelType>::ScalarRealType ScalarRealType;
68 
70  virtual void SetValidInput(const InputImageType* validImage);
71 
73  virtual void SetTestInput(const InputImageType* testImage);
74 
77  itkSetMacro(ToleranceRadius, int);
78  itkGetMacro(ToleranceRadius, int);
80 
83  itkSetMacro(DifferenceThreshold, ScalarRealType);
84  itkGetMacro(DifferenceThreshold, ScalarRealType);
86 
88  itkGetMacro(MeanDifference, RealType);
89  itkGetMacro(TotalDifference, AccumulateType);
90  itkGetMacro(NumberOfPixelsWithDifferences, unsigned long);
92 
93  void Synthetize(void) override;
94  void Reset(void) override;
95 
96 protected:
98  ~DifferenceImageFilter() = default;
99 
100  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
101 
113  void ThreadedGenerateData(const OutputImageRegionType& threadRegion, itk::ThreadIdType threadId) override;
114 
115  void GenerateOutputInformation() override;
116 
122 
123  std::vector<AccumulateType> m_ThreadDifferenceSum;
124  itk::Array<unsigned long> m_ThreadNumberOfPixels;
125 
126 private:
127  DifferenceImageFilter(const Self&) = delete;
128  void operator=(const Self&) = delete;
129 };
130 
131 } // end namespace otb
132 
133 #ifndef OTB_MANUAL_INSTANTIATION
135 #endif
136 
137 #endif
otbDifferenceImageFilter.hxx
otb::DifferenceImageFilter::m_NumberOfPixelsWithDifferences
unsigned long m_NumberOfPixelsWithDifferences
Definition: otbDifferenceImageFilter.h:120
otb::DifferenceImageFilter::m_ThreadNumberOfPixels
itk::Array< unsigned long > m_ThreadNumberOfPixels
Definition: otbDifferenceImageFilter.h:124
otbPersistentImageFilter.h
otb::DifferenceImageFilter::m_DifferenceThreshold
ScalarRealType m_DifferenceThreshold
Definition: otbDifferenceImageFilter.h:117
otb::PersistentImageFilter
This filter is the base class for all filter persisting data through multiple update....
Definition: otbPersistentImageFilter.h:47
otb::DifferenceImageFilter::ScalarRealType
itk::NumericTraits< OutputPixelType >::ScalarRealType ScalarRealType
Definition: otbDifferenceImageFilter.h:67
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::DifferenceImageFilter::Self
DifferenceImageFilter Self
Definition: otbDifferenceImageFilter.h:49
otb::DifferenceImageFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbDifferenceImageFilter.h:63
otb::DifferenceImageFilter::m_ThreadDifferenceSum
std::vector< AccumulateType > m_ThreadDifferenceSum
Definition: otbDifferenceImageFilter.h:123
otb::DifferenceImageFilter::m_ToleranceRadius
int m_ToleranceRadius
Definition: otbDifferenceImageFilter.h:121
otb::PersistentImageFilter::InputImageType
TInputImage InputImageType
Definition: otbPersistentImageFilter.h:57
otb::DifferenceImageFilter::RealType
itk::NumericTraits< OutputPixelType >::RealType RealType
Definition: otbDifferenceImageFilter.h:65
otb::DifferenceImageFilter::m_TotalDifference
AccumulateType m_TotalDifference
Definition: otbDifferenceImageFilter.h:119
otb::DifferenceImageFilter::InputImageType
TInputImage InputImageType
Definition: otbDifferenceImageFilter.h:58
otb::DifferenceImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbDifferenceImageFilter.h:62
otb::DifferenceImageFilter
Implements comparison between two images.
Definition: otbDifferenceImageFilter.h:45
otb::DifferenceImageFilter::m_MeanDifference
RealType m_MeanDifference
Definition: otbDifferenceImageFilter.h:118
otb::DifferenceImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbDifferenceImageFilter.h:52
otb::DifferenceImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbDifferenceImageFilter.h:50
otb::DifferenceImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbDifferenceImageFilter.h:51
otb::DifferenceImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbDifferenceImageFilter.h:64
otb::DifferenceImageFilter::AccumulateType
itk::NumericTraits< RealType >::AccumulateType AccumulateType
Definition: otbDifferenceImageFilter.h:66