forked from cristi-zz/pi_2020_vc_base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgorithms.h
51 lines (38 loc) · 1.36 KB
/
algorithms.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
#ifndef ALGORITHMS_H
#define ALGORITHMS_H
#include <string>
#include <vector>
#define __MAX_VALUE__ 9223372036854775807
#define INSIGNIFICANT 0.00000000001
namespace algorithms {
struct Point {
double x, y; // coordinates
long long int cluster; // no default cluster
double minHeuristic; // default infinite dist to nearest cluster
std::vector<double> features;
cv::Rect patchRect;
Point() :
x(0.0),
y(0.0),
cluster(-1),
minHeuristic(__MAX_VALUE__) {}
Point(double x, double y, cv::Rect rect) :
x(x),
y(y),
cluster(-1),
patchRect(rect),
minHeuristic(__MAX_VALUE__) {}
double heuristic(Point other, double(*heuristicFunc)(Point p, Point other)) {
return heuristicFunc(*this, other);
}
};
double euclidianHeuristic(Point p, Point other);
double cosineSimilarityHeuristic(Point p, Point other);
// Utility functions
bool compareColors(Vec3b colorA, Vec3b colorB);
std::vector<Vec3b> getRandomColors(int size);
// Algorithms
std::vector<Point> kMeansClustering(std::vector<Point>* points, int iterations, int Kclusters, double(*heuristicFunc)(Point p, Point other));
std::vector<int> binnedHistogram(Mat_<uchar> src, int numberOfBins);
};
#endif