-
Notifications
You must be signed in to change notification settings - Fork 20
/
img.cc
44 lines (40 loc) · 1.14 KB
/
img.cc
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
/* Copyright (C) 2015, Gabriele Facciolo <[email protected]>,
* Carlo de Franchis <[email protected]>,
* Enric Meinhardt <[email protected]>*/
#include "img.h"
#include <vector>
#include <stdio.h>
Img::Img(int nx, int ny, int nch)
{
this->nx = nx;
this->ny = ny;
this->nch = nch;
this->npix = nx*ny;
this->data = std::vector<float >(nx*ny*nch,0);
}
// copy row major data and create a new image
// the data is assumed to be organized in color planes
Img::Img(float *copydata, int nx, int ny, int nch)
{
this->nx = nx;
this->ny = ny;
this->nch = nch;
this->npix = nx*ny;
this->data = std::vector<float >(nx*ny*nch,0);
for(int i=0;i<nx*ny*nch;i++)
this->data[i] = copydata[i];
}
//int main(){
// struct Img c,d;
// d.data.push_back(-1.1);
// d.npix++;
// struct Img a = Img(1002,1003,3);
// a[0]=10;
// struct Img b(1000,1000,3);
// b[0]=20;
// c = b;
// c[0]++;
// c[1]=-10;
// printf("%f %f %f %f %f %f %d\n", a[0],b[0],c[0],c[1],a.val(10,10,1),d[0],d.nx);
// printf("%d %d %d %d %d\n", a.nx,a.ny,a.sz[0],a.ncol, c.sz[0]);
//}