MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkCvMatFromVnlMatrix.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 mitkCvMatFromVnlMatrix_h
13#define mitkCvMatFromVnlMatrix_h
14
15#include <mitkEndoMacros.h>
16#include <mitkEndoDebug.h>
17#include <vnl/vnl_matrix.h>
18#include <mitkAlgorithm.h>
19
20#include "opencv2/core.hpp"
21
22namespace mitk
23{
31 template <class T>
33 virtual public Algorithm
34 {
35 public:
40 const vnl_matrix<T>* _VnlMatrix,
41 cv::Mat* _CvMat):
42 m_VnlMatrix(_VnlMatrix),
43 m_CvMat(_CvMat)
44 {
45 }
46
50 template <class T_CvType, class T_VnlType>
51 static void Cast( const vnl_matrix<T_VnlType>& vnlMat, cv::Mat& cvMat )
52 {
53 endodebugvar( vnlMat )
54 cvMat = cv::Mat(vnlMat.rows(), vnlMat.cols(), cv::DataType<T_CvType>::type);
55 for(unsigned int i=0; i<vnlMat.rows(); ++i)
56 {
57 for(unsigned int j=0; j<vnlMat.cols(); ++j)
58 {
59 cvMat.at<T_CvType>(i,j) = static_cast<T_CvType>( vnlMat(i,j) );
60// endodebugvar( vnlMat(i,j) )
61// endodebugvar( cvMat.at<T_CvType>(i,j) )
62 }
63 }
64 }
65
69 void Update() override
70 {
71 Cast<T, T>( *m_VnlMatrix, *m_CvMat );
72 }
73 private:
77 const vnl_matrix<T>* m_VnlMatrix;
81 cv::Mat* m_CvMat;
82 };
83} // namespace mitk
84
85#endif
static void Cast(const vnl_matrix< T_VnlType > &vnlMat, cv::Mat &cvMat)
CvMatFromVnlMatrix(const vnl_matrix< T > *_VnlMatrix, cv::Mat *_CvMat)
#define endodebugvar(var)
IGT Exceptions.