ITK  6.0.0
Insight Toolkit
itkTestingComparisonImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkTestingComparisonImageFilter_h
19 #define itkTestingComparisonImageFilter_h
20 
21 #include "itkArray.h"
22 #include "itkNumericTraits.h"
23 #include "itkImageToImageFilter.h"
24 #include <mutex>
25 
26 namespace itk
27 {
28 namespace Testing
29 {
43 template <typename TInputImage, typename TOutputImage>
44 class ITK_TEMPLATE_EXPORT ComparisonImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
45 {
46 public:
47  ITK_DISALLOW_COPY_AND_MOVE(ComparisonImageFilter);
48 
54 
56  itkNewMacro(Self);
57 
59  itkOverrideGetNameOfClassMacro(ComparisonImageFilter);
60 
62  using InputImageType = TInputImage;
63  using InputPixelType = typename InputImageType::PixelType;
64  using OutputImageType = TOutputImage;
65  using OutputPixelType = typename OutputImageType::PixelType;
69 
71  itkSetInputMacro(ValidInput, InputImageType);
72 
74  itkSetInputMacro(TestInput, InputImageType);
75 
78  itkSetMacro(VerifyInputInformation, bool);
79  itkGetConstMacro(VerifyInputInformation, bool);
80  itkBooleanMacro(VerifyInputInformation);
85  itkSetMacro(ToleranceRadius, int);
86  itkGetConstMacro(ToleranceRadius, int);
91  itkSetMacro(DifferenceThreshold, OutputPixelType);
92  itkGetConstMacro(DifferenceThreshold, OutputPixelType);
98  itkSetMacro(IgnoreBoundaryPixels, bool);
99  itkGetConstMacro(IgnoreBoundaryPixels, bool);
100  itkBooleanMacro(IgnoreBoundaryPixels);
105  itkGetConstMacro(MinimumDifference, OutputPixelType);
106  itkGetConstMacro(MaximumDifference, OutputPixelType);
107  itkGetConstMacro(MeanDifference, RealType);
108  itkGetConstMacro(TotalDifference, AccumulateType);
109  itkGetConstMacro(NumberOfPixelsWithDifferences, SizeValueType);
112 protected:
114  ~ComparisonImageFilter() override = default;
115 
116  void
117  PrintSelf(std::ostream & os, Indent indent) const override;
118 
122  void
123  DynamicThreadedGenerateData(const OutputImageRegionType &) override;
124 
125  void
126  BeforeThreadedGenerateData() override;
127 
128  void
129  AfterThreadedGenerateData() override;
130 
131  void
132  VerifyInputInformation() const override;
133 
134  OutputPixelType m_DifferenceThreshold{};
135 
136  RealType m_MeanDifference{};
139  bool m_VerifyInputInformation{ true };
140 
141  AccumulateType m_TotalDifference{};
142 
143  SizeValueType m_NumberOfPixelsWithDifferences{ 0 };
144 
145  int m_ToleranceRadius{ 0 };
146 
147 private:
148  bool m_IgnoreBoundaryPixels{ false };
149 
150  std::mutex m_Mutex;
151 };
152 } // end namespace Testing
153 } // end namespace itk
154 
155 #ifndef ITK_MANUAL_INSTANTIATION
156 # include "itkTestingComparisonImageFilter.hxx"
157 #endif
158 
159 
160 #endif
itk::Testing::ComparisonImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkTestingComparisonImageFilter.h:65
itk::Testing::ComparisonImageFilter::m_Mutex
std::mutex m_Mutex
Definition: itkTestingComparisonImageFilter.h:150
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:99
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Testing::ComparisonImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkTestingComparisonImageFilter.h:63
itk::Testing::ComparisonImageFilter
Implements comparison between two images.
Definition: itkTestingComparisonImageFilter.h:44
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:169
itkArray.h
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::Testing::ComparisonImageFilter::RealType
typename NumericTraits< OutputPixelType >::RealType RealType
Definition: itkTestingComparisonImageFilter.h:67
itk::Testing::ComparisonImageFilter::AccumulateType
typename NumericTraits< RealType >::AccumulateType AccumulateType
Definition: itkTestingComparisonImageFilter.h:68
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itkNumericTraits.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90