Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkCvMatCompare.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 #ifndef mitkCvMatCompare_h
13 #define mitkCvMatCompare_h
14 
15 #include <mitkEpsilon.h>
16 #include <mitkObservable.h>
17 #include <mitkAlgorithm.h>
18 #include <mitkEndoDebug.h>
19 
20 namespace mitk
21 {
25  class CvMatCompare:
26  virtual public Algorithm
27  {
28  public:
33  const Epsilon* _Epsilon,
34  bool* _Equals):
35  m_CvMat1(nullptr),
36  m_CvMat2(nullptr),
37  m_Epsilon(_Epsilon),
38  m_Equals(_Equals)
39  {
40  }
45  const cv::Mat* _CvMat1,
46  const cv::Mat* _CvMat2,
47  const Epsilon* _Epsilon,
48  bool* _Equals):
49  m_CvMat1(_CvMat1),
50  m_CvMat2(_CvMat2),
51  m_Epsilon(_Epsilon),
52  m_Equals(_Equals)
53  {
54  }
55 
56  void SetMatrices( const cv::Mat* _CvMat1, const cv::Mat* _CvMat2 )
57  {
58  m_CvMat1 = _CvMat1;
59  m_CvMat2 = _CvMat2;
60  }
61 
62  void SetMatrix1( const cv::Mat* _CvMat1 )
63  {
64  m_CvMat1 = _CvMat1;
65  }
66  void SetMatrix2( const cv::Mat* _CvMat2 )
67  {
68  m_CvMat2 = _CvMat2;
69  }
70 
74  void Update() override
75  {
76  assert( m_CvMat1 && m_CvMat2 );
77  cv::Mat dst;
78  cv::absdiff( (*m_CvMat1), (*m_CvMat2), dst);
79  double max = 0;
80  cv::minMaxLoc( dst, nullptr, &max );
81 
82  endodebugvar( max )
83 
84  (*m_Equals) = max <= *m_Epsilon;
85  }
86  private:
90  const cv::Mat* m_CvMat1;
94  const cv::Mat* m_CvMat2;
98  const Epsilon* m_Epsilon;
102  bool* m_Equals;
103  };
104 } // namespace mitk
105 
106 #endif
endodebugvar
#define endodebugvar(var)
Definition: mitkEndoDebug.h:214
mitk::CvMatCompare::Update
void Update() override
Definition: mitkCvMatCompare.h:74
mitk::CvMatCompare
Definition: mitkCvMatCompare.h:25
mitkEpsilon.h
mitkEndoDebug.h
mitk::CvMatCompare::SetMatrices
void SetMatrices(const cv::Mat *_CvMat1, const cv::Mat *_CvMat2)
Definition: mitkCvMatCompare.h:56
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitkObservable.h
mitk::CvMatCompare::SetMatrix1
void SetMatrix1(const cv::Mat *_CvMat1)
Definition: mitkCvMatCompare.h:62
mitk::CvMatCompare::SetMatrix2
void SetMatrix2(const cv::Mat *_CvMat2)
Definition: mitkCvMatCompare.h:66
mitk::Algorithm
Definition: mitkAlgorithm.h:22
mitk::CvMatCompare::CvMatCompare
CvMatCompare(const Epsilon *_Epsilon, bool *_Equals)
Definition: mitkCvMatCompare.h:32
mitkAlgorithm.h
mitk::CvMatCompare::CvMatCompare
CvMatCompare(const cv::Mat *_CvMat1, const cv::Mat *_CvMat2, const Epsilon *_Epsilon, bool *_Equals)
Definition: mitkCvMatCompare.h:44
mitk::Epsilon
double Epsilon
Definition: mitkEpsilon.h:20