Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
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 // mitkCvMatCompare_h
void Update() override
CvMatCompare(const Epsilon *_Epsilon, bool *_Equals)
double Epsilon
Definition: mitkEpsilon.h:20
void SetMatrix1(const cv::Mat *_CvMat1)
DataCollection - Class to facilitate loading/accessing structured data.
void SetMatrices(const cv::Mat *_CvMat1, const cv::Mat *_CvMat2)
static T max(T x, T y)
Definition: svm.cpp:56
CvMatCompare(const cv::Mat *_CvMat1, const cv::Mat *_CvMat2, const Epsilon *_Epsilon, bool *_Equals)
void SetMatrix2(const cv::Mat *_CvMat2)
#define endodebugvar(var)