-
Notifications
You must be signed in to change notification settings - Fork 53
/
MeanShift.h
27 lines (22 loc) · 951 Bytes
/
MeanShift.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
#pragma once
#include <vector>
struct Cluster {
std::vector<double> mode;
std::vector<std::vector<double> > original_points;
std::vector<std::vector<double> > shifted_points;
};
class MeanShift {
public:
typedef std::vector<double> Point;
MeanShift() { set_kernel(NULL); }
MeanShift(double (*_kernel_func)(double,double)) { set_kernel(kernel_func); }
std::vector<Point> meanshift(const std::vector<Point> & points,
double kernel_bandwidth,
double EPSILON = 0.00001);
std::vector<Cluster> cluster(const std::vector<Point> &, double);
private:
double (*kernel_func)(double,double);
void set_kernel(double (*_kernel_func)(double,double));
void shift_point(const Point&, const std::vector<Point> &, double, Point&);
std::vector<Cluster> cluster(const std::vector<Point> &, const std::vector<Point> &);
};