Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkCompareImageDataFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkCompareImageDataFilter_h
14 #define mitkCompareImageDataFilter_h
15 
16 // MITK
17 #include <mitkImage.h>
18 #include <mitkImageToImageFilter.h>
19 
20 // ITK
21 #include <itkImage.h>
22 
23 namespace mitk
24 {
30  {
32  void PrintSelf()
33  {
34  if (!m_FilterCompleted)
35  {
36  MITK_INFO << "Comparison filter terminated due to an exception: \n " << m_ExceptionMessage;
37 
38  return;
39  }
40 
41  MITK_INFO << "Min. difference: " << m_MinimumDifference << "\n"
42  << "Max. difference: " << m_MaximumDifference << "\n"
43  << "Total difference: " << m_TotalDifference << "\n"
44  << "Mean difference: " << m_MeanDifference << "\n"
45  << "Number of pixels with differences: " << m_PixelsWithDifference;
46  }
47 
50 
54 
56  std::string m_ExceptionMessage;
57  };
58 
70  {
71  public:
74 
87  bool GetResult(size_t threshold = 0);
88 
94  CompareFilterResults GetCompareResults() { return m_CompareDetails; }
95 
100  void SetTolerance(double eps) { m_Tolerance = eps; }
101 
102  protected:
107 
109  void GenerateData() override;
110 
113 
119  template <typename TPixel, unsigned int VImageDimension>
120  void EstimateValueDifference(const itk::Image<TPixel, VImageDimension> *itkImage1,
121  const mitk::Image *referenceImage);
122 
125  double m_Tolerance;
126  };
127 } // end namespace mitk
128 
129 #endif
#define MITKCORE_EXPORT
Filter for pixel-wise comparison of two mitk::Image objects.
~CompareImageDataFilter() override
Destructor.
CompareFilterResults m_CompareDetails
Detailed comparison statistics.
mitkClassMacro(CompareImageDataFilter, ImageToImageFilter)
double m_Tolerance
Per-pixel tolerance value.
void ResetCompareResultsToInitial()
Reset the comparison detail struct to its initial state.
void GenerateData() override
Perform the pixel-wise comparison.
CompareFilterResults GetCompareResults()
Get the detailed results of the comparison run.
bool m_CompareResult
Overall pass/fail result.
bool GetResult(size_t threshold=0)
Check whether the comparison passes a given threshold.
CompareImageDataFilter()
Constructor. Sets the number of required inputs to 2.
void EstimateValueDifference(const itk::Image< TPixel, VImageDimension > *itkImage1, const mitk::Image *referenceImage)
Run itk::Testing::ComparisonImageFilter on the two inputs.
void SetTolerance(double eps)
Set the tolerance for per-pixel difference comparison.
Superclass of all classes having one or more Images as input and generating Images as output.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
#define MITK_INFO
Log an informational message.
Definition: mitkLog.h:358
Find image slices visible on a given plane.
MITKCORE_EXPORT const ScalarType eps
Epsilon value for floating point comparison (vnl_math::eps * 100).
Holds the detailed results of a CompareImageDataFilter comparison.
double m_MaximumDifference
Largest per-pixel difference found.
std::string m_ExceptionMessage
Exception message if the filter did not complete.
size_t m_PixelsWithDifference
Number of pixels that differ beyond tolerance.
double m_TotalDifference
Sum of all per-pixel differences.
double m_MinimumDifference
Smallest per-pixel difference found.
bool m_FilterCompleted
Whether the comparison finished without exception.
double m_MeanDifference
Mean per-pixel difference.
void PrintSelf()
Print the comparison results to MITK_INFO.