soft-matter/trackpy — pull request #143 by danielballan (2014-08-13 01:04:54+00:00)
Title: ENH: Merge nearby peaks by picking most massive neighborhood.

Sometimes, a single features registers multiple local maxima. The problem of merging duplicate maxima ("flat peaks") into one feature has been handled two different ways. This introduces a third, best way.

1. Originally, this was handled (a la Crocker-Grier) by passing a filter over the entire "peak map" image which knocked out any peak that wasn't the brightest pixel in the neighborhood. This is a slow strategy, and it required a C extension, so in #85 we changed strategies to...
2. Use `cKDTree` to identify nearby peaks. These peaks were then merged by *averaging their position*. This is OK for flat peaks, but it can easily go wrong if `separation` is large enough to touch other features. It was a bad choice. Instead this proposes:
3. Use `cKDTree`. To "merge" peaks, just pick a winner. Use the peak with the brightest total neighborhood, and discard the rest.

Dark red circles -- current behavior.
Green circles -- this PR

![comparison](https://cloud.githubusercontent.com/assets/2279598/3900067/12e11a14-2285-11e4-865c-4e7d67a4b17e.gif)