Get coordinates of local maxima in 2D array above certain value

后端 未结 3 894
心在旅途
心在旅途 2020-11-30 22:04
from PIL import Image
import numpy as np
from scipy.ndimage.filters import maximum_filter
import pylab

# the picture (256 * 256 pixels) contains bright spots of whi         


        
3条回答
  •  情书的邮戳
    2020-11-30 22:52

    This can now be done with skimage.

    from skimage.feature import peak_local_max
    xy = peak_local_max(data, min_distance=2,threshold_abs=1500)
    

    On my computer, for a VGA image size it runs about 4x faster than the above solution and also returned a more accurate position in certain cases.

提交回复
热议问题