diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py index 8bac92bf..dd4c824c 100644 --- a/skimage/feature/peak.py +++ b/skimage/feature/peak.py @@ -151,10 +151,11 @@ def peak_local_max(image, min_distance=1, threshold_abs=None, mask &= image > max(thresholds) # get coordinates of peaks - coordinates = np.argwhere(image > peak_threshold) + coordinates = np.transpose(mask.nonzero()) if coordinates.shape[0] > num_peaks: - intensities = image.flat[np.ravel_multi_index(coordinates.transpose(),image.shape)] + intensities = image.flat[np.ravel_multi_index(coordinates.transpose(), + image.shape)] idx_maxsort = np.argsort(intensities)[::-1] coordinates = coordinates[idx_maxsort][:num_peaks]