[SciPy-user] Extrema finding
Thu Oct 9 14:06:33 CDT 2008
This is a version for finding extrema in a 2D array. It requires the
ndimage maximum/minimum filters. For the one dimensional case
substitute size= or use maximum_filter1d. I keep writing this code
over and over. I am surprised that there is not a general purpose
extrema finding routine in scipy.
mx = maximum_filter(mat, size=[3,3])
mn = minimum_filter(mat, size=[3,3])
# (mat == mx) true if pixel is equal to the local max
# The next computation suppresses responses where
# the function is flat.
local_maxima = ((mat == mx) & (mat != mn))
# Get the indices of the maxima
extrema = nonzero(local_maxima)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user