-
Notifications
You must be signed in to change notification settings - Fork 0
/
VectorCaracteristico.h
53 lines (42 loc) · 1.1 KB
/
VectorCaracteristico.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
#ifndef VECTORCARACTERISTICO
#define VECTORCARACTERISTICO
#define cimg_use_jpeg 1
#include "CImg.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using namespace cimg_library;
template <typename T>
class VectorCaracteristico {
vector<T>* vc;
public:
char imgPath[200];
VectorCaracteristico(const char* imgPath) {
strcpy(this->imgPath, imgPath);
CImg<T> A(imgPath);
CImg<T> B = A.haar(false, 1);
CImg<T> C = B.crop(0, 0, 89, 99);
this->vc = vectorizar(C);
}
void printName() {
cout << imgPath << "\n";
}
vector<T>* get() {
return vc;
}
private:
vector<T>* vectorizar(CImg<T>& img) {
vector<T>* r = new vector<T>();
cimg_forXY (img, x, y) {
r->push_back( (
img(x, y, 0) +
img(x, y, 1) +
img(x, y, 2)
)/3.0f
);
}
return r;
}
};
#endif