def find_peaks_minmax(z, separation=5., threshold=10.):
"""
Method to locate the positive peaks in an image by comparing maximum
and minimum filtered images.
Parameters
----------
z : ndarray
Matrix of image intensities.
separation : float
Expected distance between peaks.
threshold : float
Minimum difference between maximum and minimum filtered images.
Returns
-------
peaks: array with dimensions (npeaks, 2) that contains the x, y coordinates
for each peak found in the image.
"""
data_max = ndi.filters.maximum_filter(z, separation)
maxima = (z == data_max)
data_min = ndi.filters.minimum_filter(z, separation)
diff = ((data_max - data_min) > threshold)
maxima[diff == 0] = 0
labeled, num_objects = ndi.label(maxima)
peaks = np.array(
ndi.center_of_mass(z, labeled, range(1, num_objects + 1)))
return clean_peaks(peaks)
评论列表
文章目录