From 233b368195d6beaeba84794b5bfd8663e2bf45f2 Mon Sep 17 00:00:00 2001 From: "Josh Warner (Mac)" Date: Tue, 20 Nov 2012 00:45:01 -0600 Subject: [PATCH] BUG - Fixed a bug where the image was not properly masked for each unique label. --- skimage/feature/peak.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py index ffa942c4..fcd088c6 100644 --- a/skimage/feature/peak.py +++ b/skimage/feature/peak.py @@ -108,13 +108,14 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1, out = np.zeros_like(image) for label in labels: - out += peak_local_max(image, min_distance=min_distance, - threshold_abs=threshold_abs, - threshold_rel=threshold_rel, - exclude_border=exclude_border, - indices=False, num_peaks=np.inf, - footprint=footprint, labels=None, - **kwargs) + maskim = (labels == label) + out += peak_local_max(image * maskim, min_distance=min_distance, + threshold_abs=threshold_abs, + threshold_rel=threshold_rel, + exclude_border=exclude_border, + indices=False, num_peaks=np.inf, + footprint=footprint, labels=None, + **kwargs) if indices is True: return np.transpose(out.nonzero())