-
Notifications
You must be signed in to change notification settings - Fork 2
/
FeatureExtractor.cpp
executable file
·56 lines (45 loc) · 1.52 KB
/
FeatureExtractor.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
//
// FeatureExtractor.cpp
// segmenthreetion
//
// Created by Albert Clapés on 17/02/14.
//
//
#include "FeatureExtractor.h"
FeatureExtractor::FeatureExtractor()
{
}
void FeatureExtractor::describe(ModalityGridData& data)
{
for (int k = 0; k < data.getGridsFrames().size(); k++)
{
if (k % 1000 == 0) cout << 100.0 * k / data.getGridsFrames().size() << "%" << endl; // debug
//cout << k << endl;
// Normal image description
GridMat grid = data.getGridFrame(k);
GridMat gmask = data.getGridMask(k);
cv::Mat gvalidness = data.getValidnesses(k);
GridMat gdescriptors;
describe(grid, gmask, gvalidness, gdescriptors);
// Mirrored image description
int flipCode = 1;
GridMat gridMirrored = grid.flip(flipCode); // flip respect the vertical axis
GridMat gmaskMirrored = gmask.flip(flipCode);
cv::Mat gvalidnessMirrored;
cv::flip(gvalidness, gvalidnessMirrored, flipCode);
GridMat gdescriptorsMirrored;
describe(gridMirrored, gmaskMirrored, gvalidnessMirrored, gdescriptorsMirrored);
// Add to the descriptors to the data
data.addDescriptors(gdescriptors);
data.addDescriptorsMirrored(gdescriptorsMirrored);
}
}
/*
* Hypercube normalization
*/
void FeatureExtractor::hypercubeNorm(cv::Mat & src, cv::Mat & dst)
{
src.copyTo(dst);
double z = sum(src).val[0]; // partition function :D
dst = dst / z;
}