ITK  5.4.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 
25 namespace itk
26 {
27 namespace Testing
28 {
42 template <typename TInputImage, typename TOutputImage>
43 class ITK_TEMPLATE_EXPORT ComparisonImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
44 {
45 public:
46  ITK_DISALLOW_COPY_AND_MOVE(ComparisonImageFilter);
47 
53 
55  itkNewMacro(Self);
56 
58  itkOverrideGetNameOfClassMacro(ComparisonImageFilter);
59 
61  using InputImageType = TInputImage;
62  using InputPixelType = typename InputImageType::PixelType;
63  using OutputImageType = TOutputImage;
64  using OutputPixelType = typename OutputImageType::PixelType;
68 
70  itkSetInputMacro(ValidInput, InputImageType);
71 
73  itkSetInputMacro(TestInput, InputImageType);
74 
77  itkSetMacro(VerifyInputInformation, bool);
78  itkGetConstMacro(VerifyInputInformation, bool);
79  itkBooleanMacro(VerifyInputInformation);
84  itkSetMacro(ToleranceRadius, int);
85  itkGetConstMacro(ToleranceRadius, int);
90  itkSetMacro(DifferenceThreshold, OutputPixelType);
91  itkGetConstMacro(DifferenceThreshold, OutputPixelType);
97  itkSetMacro(IgnoreBoundaryPixels, bool);
98  itkGetConstMacro(IgnoreBoundaryPixels, bool);
99  itkBooleanMacro(IgnoreBoundaryPixels);
104  itkGetConstMacro(MinimumDifference, OutputPixelType);
105  itkGetConstMacro(MaximumDifference, OutputPixelType);
106  itkGetConstMacro(MeanDifference, RealType);
107  itkGetConstMacro(TotalDifference, AccumulateType);
108  itkGetConstMacro(NumberOfPixelsWithDifferences, SizeValueType);
111 protected:
113  ~ComparisonImageFilter() override = default;
114 
115  void
116  PrintSelf(std::ostream & os, Indent indent) const override;
117 
127  void
128  ThreadedGenerateData(const OutputImageRegionType & threadRegion, ThreadIdType threadId) override;
129 
130  void
132  {
133  itkExceptionMacro("This class requires threadId so it must use classic multi-threading model");
134  }
135 
136  void
137  BeforeThreadedGenerateData() override;
138 
139  void
140  AfterThreadedGenerateData() override;
141 
142  void
143  VerifyInputInformation() ITKv5_CONST override;
144 
145  OutputPixelType m_DifferenceThreshold{};
146 
147  RealType m_MeanDifference{};
148  OutputPixelType m_MinimumDifference{};
149  OutputPixelType m_MaximumDifference{};
150  bool m_VerifyInputInformation{};
151 
152  AccumulateType m_TotalDifference{};
153 
154  SizeValueType m_NumberOfPixelsWithDifferences{};
155 
156  int m_ToleranceRadius{};
157 
158  Array<AccumulateType> m_ThreadDifferenceSum{};
159  Array<SizeValueType> m_ThreadNumberOfPixels{};
160 
161  Array<OutputPixelType> m_ThreadMinimumDifference{};
162  Array<OutputPixelType> m_ThreadMaximumDifference{};
163 
164 private:
165  bool m_IgnoreBoundaryPixels{};
166 };
167 } // end namespace Testing
168 } // end namespace itk
169 
170 #ifndef ITK_MANUAL_INSTANTIATION
171 # include "itkTestingComparisonImageFilter.hxx"
172 #endif
173 
174 
175 #endif
itk::Testing::ComparisonImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkTestingComparisonImageFilter.h:64
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:62
itk::Testing::ComparisonImageFilter
Implements comparison between two images.
Definition: itkTestingComparisonImageFilter.h:43
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
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:59
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:66
itk::Testing::ComparisonImageFilter::AccumulateType
typename NumericTraits< RealType >::AccumulateType AccumulateType
Definition: itkTestingComparisonImageFilter.h:67
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Testing::ComparisonImageFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const OutputImageRegionType &) override
Definition: itkTestingComparisonImageFilter.h:131
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Array< AccumulateType >
itkNumericTraits.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90