Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef mitkCvMatCompare_h
17 #define mitkCvMatCompare_h
18 
19 #include <mitkEpsilon.h>
20 #include <mitkObservable.h>
21 #include <mitkAlgorithm.h>
22 #include <mitkEndoDebug.h>
23 
24 namespace mitk
25 {
29  class CvMatCompare:
30  virtual public Algorithm
31  {
32  public:
37  const Epsilon* _Epsilon,
38  bool* _Equals):
39  m_CvMat1(nullptr),
40  m_CvMat2(nullptr),
41  m_Epsilon(_Epsilon),
42  m_Equals(_Equals)
43  {
44  }
49  const cv::Mat* _CvMat1,
50  const cv::Mat* _CvMat2,
51  const Epsilon* _Epsilon,
52  bool* _Equals):
53  m_CvMat1(_CvMat1),
54  m_CvMat2(_CvMat2),
55  m_Epsilon(_Epsilon),
56  m_Equals(_Equals)
57  {
58  }
59 
60  void SetMatrices( const cv::Mat* _CvMat1, const cv::Mat* _CvMat2 )
61  {
62  m_CvMat1 = _CvMat1;
63  m_CvMat2 = _CvMat2;
64  }
65 
66  void SetMatrix1( const cv::Mat* _CvMat1 )
67  {
68  m_CvMat1 = _CvMat1;
69  }
70  void SetMatrix2( const cv::Mat* _CvMat2 )
71  {
72  m_CvMat2 = _CvMat2;
73  }
74 
78  void Update() override
79  {
80  assert( m_CvMat1 && m_CvMat2 );
81  cv::Mat dst;
82  cv::absdiff( (*m_CvMat1), (*m_CvMat2), dst);
83  double max = 0;
84  cv::minMaxLoc( dst, nullptr, &max );
85 
86  endodebugvar( max )
87 
88  (*m_Equals) = max <= *m_Epsilon;
89  }
90  private:
94  const cv::Mat* m_CvMat1;
98  const cv::Mat* m_CvMat2;
102  const Epsilon* m_Epsilon;
106  bool* m_Equals;
107  };
108 } // namespace mitk
109 
110 #endif // mitkCvMatCompare_h
void Update() override
CvMatCompare(const Epsilon *_Epsilon, bool *_Equals)
double Epsilon
Definition: mitkEpsilon.h:24
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:70
CvMatCompare(const cv::Mat *_CvMat1, const cv::Mat *_CvMat2, const Epsilon *_Epsilon, bool *_Equals)
void SetMatrix2(const cv::Mat *_CvMat2)
#define endodebugvar(var)