peakfinders2D.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:pyxem 作者: pyxem 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号