mattnedrich/MeanShift_cpp

Refactoring to templates

Closed this issue · 2 comments

Hi,

performance wise, I noticed that the way you use std::vector to store the multidimensional points is very inefficient, mainly because std::vector will require a memory allocation.

Most of the time the dimension of the points is known at compilation time. This means that points are usually stored in an already known data structure or in a std:.array.

I would like to send a pull request that solve this problem and use templates to accept any type.
Would you accept this PR?

Regards

Davide

I think this is reasonable and nice feedback. I wrote my implementation as an example - not necessarily expecting anything to come of it or for anyone to use it. I've merged your PR. Thanks for the feedback and taking the time to open the PR.

Yes, I read the original article (very useful) and I guessed that you didn't plan to work much on this code, since it had only a didactic purpose.

For the records, the templatized version can be found here:

https://github.com/Eurecat/MeanShift_cpp/tree/template

It is considerably faster when std::array is used instead of std::vector.
But I do agree that a newbie that looks at the code just to understand the algorithm might be confused by the templates.

Cheers and thanks for sharing