MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkVnlMatrixFromCvMat.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12#ifndef mitkVnlMatrixFromCvMat_h
13#define mitkVnlMatrixFromCvMat_h
14
15#include <vnl/vnl_matrix.h>
16#include <opencv2/core.hpp>
17#include <mitkObservable.h>
18#include <mitkAlgorithm.h>
19#include <mitkEndoMacros.h>
20
21namespace mitk
22{
26 template <class T>
28 virtual public Algorithm
29 {
30 public:
35 const cv::Mat* _CvMat,
36 vnl_matrix<T>* _VnlMatrix):
37 m_CvMat(_CvMat),
38 m_VnlMatrix(_VnlMatrix)
39 {
40 }
41
42
46 template <typename TCvMat, typename TVnlMat>
47 void ToVnlMatrix( vnl_matrix<TVnlMat>& vnlMat, const cv::Mat& mat )
48 {
49 vnlMat.set_size( mat.rows, mat.cols );
50 for(int i=0; i<mat.rows; ++i)
51 for(int j=0; j<mat.cols; ++j)
52 vnlMat(i,j) = static_cast<TVnlMat>( mat.at<TCvMat>(i,j) );
53 }
54
58 void Update() override
59 {
60 endoAccessCvMat( ToVnlMatrix, T, (*m_VnlMatrix), (*m_CvMat) );
61 }
62 private:
66 const cv::Mat* m_CvMat;
70 vnl_matrix<T>* m_VnlMatrix;
71 };
72} // namespace mitk
73
74#endif
VnlMatrixFromCvMat(const cv::Mat *_CvMat, vnl_matrix< T > *_VnlMatrix)
void ToVnlMatrix(vnl_matrix< TVnlMat > &vnlMat, const cv::Mat &mat)
#define endoAccessCvMat(function, T, arg1, arg2)
IGT Exceptions.