ITK  5.2.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  * http://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 
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);
81 
84  itkSetMacro(ToleranceRadius, int);
85  itkGetConstMacro(ToleranceRadius, int);
87 
90  itkSetMacro(DifferenceThreshold, OutputPixelType);
91  itkGetConstMacro(DifferenceThreshold, OutputPixelType);
93 
97  itkSetMacro(IgnoreBoundaryPixels, bool);
98  itkGetConstMacro(IgnoreBoundaryPixels, bool);
100 
103  itkGetConstMacro(MinimumDifference, OutputPixelType);
104  itkGetConstMacro(MaximumDifference, OutputPixelType);
105  itkGetConstMacro(MeanDifference, RealType);
106  itkGetConstMacro(TotalDifference, AccumulateType);
107  itkGetConstMacro(NumberOfPixelsWithDifferences, SizeValueType);
109 
110 protected:
112  ~ComparisonImageFilter() override = default;
113 
114  void
115  PrintSelf(std::ostream & os, Indent indent) const override;
116 
126  void
127  ThreadedGenerateData(const OutputImageRegionType & threadRegion, ThreadIdType threadId) override;
128 
129  void
131  {
132  itkExceptionMacro("This class requires threadId so it must use classic multi-threading model");
133  }
134 
135  void
136  BeforeThreadedGenerateData() override;
137 
138  void
139  AfterThreadedGenerateData() override;
140 
141  void
142  VerifyInputInformation() ITKv5_CONST override;
143 
144  OutputPixelType m_DifferenceThreshold;
145 
146  RealType m_MeanDifference;
147  OutputPixelType m_MinimumDifference;
148  OutputPixelType m_MaximumDifference;
149  bool m_VerifyInputInformation;
150 
151  AccumulateType m_TotalDifference;
152 
153  SizeValueType m_NumberOfPixelsWithDifferences;
154 
155  int m_ToleranceRadius;
156 
157  Array<AccumulateType> m_ThreadDifferenceSum;
158  Array<SizeValueType> m_ThreadNumberOfPixels;
159 
160  Array<OutputPixelType> m_ThreadMinimumDifference;
161  Array<OutputPixelType> m_ThreadMaximumDifference;
162 
163 private:
164  bool m_IgnoreBoundaryPixels;
165 };
166 } // end namespace Testing
167 } // end namespace itk
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 # include "itkTestingComparisonImageFilter.hxx"
171 #endif
172 
173 
174 #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:58
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:130
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itkNumericTraits.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90