Skip to content

Commit

Permalink
Merge pull request scikit-image#1 from jni/peak-local-max-indices-nd
Browse files Browse the repository at this point in the history
Make `exclude_borders` option in peak_local_max nD
  • Loading branch information
zetyang committed Apr 3, 2013
2 parents afde2b8 + 6e4ec78 commit 4a4517c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions skimage/feature/peak.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
image *= mask

if exclude_border:
# Remove the image borders
image[:min_distance] = 0
image[-min_distance:] = 0
image[:, :min_distance] = 0
image[:, -min_distance:] = 0
# zero out the image borders
for i in range(image.ndim):
image = image.swapaxes(0, i)
image[:min_distance] = 0
image[-min_distance:] = 0
image = image.swapaxes(0, i)

# find top peak candidates above a threshold
peak_threshold = max(np.max(image.ravel()) * threshold_rel, threshold_abs)
Expand Down

0 comments on commit 4a4517c

Please sign in to comment.