Merge pull request #1 from jni/peak-local-max-indices-nd

Make `exclude_borders` option in peak_local_max nD
This commit is contained in:
yangzetian
2013-04-03 03:03:08 -07:00
+6 -5
View File
@@ -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)