-
Notifications
You must be signed in to change notification settings - Fork 0
/
sig.cpp
67 lines (58 loc) · 1.54 KB
/
sig.cpp
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
#include <stdio.h>
#include <CImg.h>
#include "sig.h"
using namespace cimg_library;
SigStruct *pathSig(char *path) {
CImg<unsigned char> img(path);
SigStruct *sig = imgSig(&img);
return sig;
}
SigStruct *imgSig(CImg<unsigned char> *img) {
img->resize(NUM_PIXELS, NUM_PIXELS);
static Unit cdata1[NUM_PIXELS_SQUARED];
static Unit cdata2[NUM_PIXELS_SQUARED];
static Unit cdata3[NUM_PIXELS_SQUARED];
unsigned char rchan[NUM_PIXELS_SQUARED];
unsigned char gchan[NUM_PIXELS_SQUARED];
unsigned char bchan[NUM_PIXELS_SQUARED];
int i = 0;
cimg_for(img->get_shared_channel(0), p, unsigned char) {
rchan[i] = *p;
i++;
}
i = 0;
cimg_for(img->get_shared_channel(1), p, unsigned char) {
gchan[i] = *p;
i++;
}
i = 0;
cimg_for(img->get_shared_channel(2), p, unsigned char) {
bchan[i] = *p;
i++;
}
transformChar(rchan, gchan, bchan, cdata1, cdata2, cdata3);
SigStruct *nsig = new SigStruct();
calcHaar(cdata1, cdata2, cdata3,
nsig->sig1, nsig->sig2, nsig->sig3, nsig->avgl);
return nsig;
}
void printSig(SigStruct *sig) {
printSigSect(sig->sig1);
printSigSect(sig->sig2);
printSigSect(sig->sig3);
}
void printSigObj(SigStruct *sig) {
printSig(sig);
// avg lum
for (int i=0; i<3; i++) {
printf("%e ", sig->avgl[i]);
}
printf("\n");
}
void printSigSect(Idx *sigSect) {
for (int i=0; i<NUM_COEFS; i++) {
// typedef int Idx
printf("%d ", sigSect[i]);
}
printf("\n");
}