matcell.cpp
1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "matcell.h"
MatCell::MatCell()
{
_elements.clear();
}
MatCell::MatCell(int nbElements)
{
_elements.clear();
_elements = std::vector<cv::Mat_<double>>(nbElements);
}
MatCell::~MatCell()
{
}
void MatCell::eachAssign(const cv::Mat &m)
{
for (int i = 0; i < (int)_elements.size(); i++)
_elements[i] = m;
}
void MatCell::eachMultiplyLeft(const cv::Mat &m)
{
for (int i = 0; i < (int)_elements.size(); i++)
_elements[i] = m * _elements[i];
}
void MatCell::eachMultiplyRight(const cv::Mat &m)
{
for (int i = 0; i < (int)_elements.size(); i++)
_elements[i] = _elements[i] * m;
}
cv::Mat_<double> &MatCell::operator[](const int index)
{
return _elements[index];
}
cv::Mat MatCell::toMat()
{
cv::Mat_<double> a;
for (int i = 0; i < (int)_elements.size(); i++){
a.push_back(_elements[i]);
}
return a;
}
MatCell::operator cv::Mat_<double>() const {
cv::Mat_<double> a;
for (int i = 0; i < (int)_elements.size(); i++){
a.push_back(_elements[i]);
}
return a;
}