hierarchicalClustering with custom distance

asked 2017-02-27 07:57:07 -0600

Humam Helfawi gravatar image

How can use cv::hierarchicalClustering with custom distance? how should the operator declaration should be?

for example if I have 2D dataset, I want something like this:

[](auto l, auto r){ 
    return l[0]*r[0]+l[1]r[1];
}

How can I prepare it to be passed to cv::hierarchicalClustering

edit retag flag offensive close merge delete

Comments

berak gravatar imageberak ( 2017-02-27 08:30:32 -0600 )edit

@berak yes. but my question about how the distance function should be declared

Humam Helfawi gravatar imageHumam Helfawi ( 2017-02-28 01:06:48 -0600 )edit

no idea, if it is possible at all, but Distance is a template object, it needs an operator () and some more things. for sure you won't get away with a simple lambda.. have a look at the L2 implementation

berak gravatar imageberak ( 2017-02-28 01:36:40 -0600 )edit

@berak, yup I saw it and that what makes me ask here :D. Thank you for your time :)

Humam Helfawi gravatar imageHumam Helfawi ( 2017-02-28 07:44:15 -0600 )edit