# [SciPy-user] Finding clustered vectors

Robert kxroberto at googlemail.com
Thu Nov 23 07:26:42 CST 2006

```Aaron Hoover wrote:
> Hi all,
>
> I've got a question maybe some of you can help me with. I have two
> images, one of which is a planar translation of the other, so I know
> it contains some of the same "features" (using this loosely) as the
> first image. I have some different approaches matching features and
> using those results to calculate candidate 2D shift vectors for each
> 2 image sequence. Most of the time, those vectors aren't all the same
> due to noise, imperfect matching, features leaving the frame, etc.
> However there are usually at least a few whose dx and dy values are
> very close, while the others are somewhat noisy and relatively
> randomly distributed.
>
> My question is, what's the best way to get those values in that
> cluster? I've tried some very simple statistical methods, but because
> of outliers and things, simply comparing to the mean and/or variance
> hasn't worked too well. Basically, if I *know* there's going to be a
> cluster of at least 2 vectors with nearly the same values how can I
> easily extract those values (or the mean of those values)?
>

There are complex cluster algs. But your problem seems to be very small compared to the amount of beforehand computation.
Thus maybe just do this simple O(2) alg:

* walk each point
* collect(sum of e.g. (1/(distance+CONST)) vs. each other point,p)
* sort points regarding the sum
* take the mean of the last 3 or last 20% point or so...

Robert

```