-
Notifications
You must be signed in to change notification settings - Fork 3
/
imagesymmmat.h
72 lines (59 loc) · 1.32 KB
/
imagesymmmat.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef IMAGESYMMMAT_H
#define IMAGESYMMMAT_H
#include <cassert>
#include <cstring>
#include <vector>
using namespace std;
class ImageSymmMat
{
private:
int w, h, size;
float *pmat;
public:
ImageSymmMat(const int width, const int height)
{
w = width;
h = height;
size = width*height*3;
pmat = new float[size];
memset(pmat, 0, size*sizeof(float));
}
void pSet(const int x, const int y, const float *mat)
{
assert(mat);
if(x >= w || y >= h)
return ;
int cusor = 3*(y*w + x);
pmat[cusor] = mat[0] ;
pmat[cusor+1] = mat[1] ;
pmat[cusor+2] = mat[2] ;
}
void pSet(const int x, const int y, const float a, const float b, const float c)
{
if(x >= w || y >= h)
return ;
int cusor = 3*(y*w + x);
pmat[cusor] = a;
pmat[cusor+1] = b;
pmat[cusor+2] = c;
}
void pGet(const int x, const int y, float &a, float &b, float &c)
{
if(x >= w || y >= h)
{
a = c = 0;
b = 0;
return ;
}
int cusor = 3*(y*w + x);
assert(cusor < size);
a = pmat[cusor];
b = pmat[cusor+1];
c = pmat[cusor+2];
}
~ImageSymmMat()
{
delete [] pmat;
}
};
#endif