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 which I wanna get positions
# problem: data has high background around value 900 - 1000
im = Image.open('slice0000.png')
data = np.array(im)
# as far as I understand, data == maximum_filter gives True-value for pixels
# being the brightest in their neighborhood (here 10 * 10 pixels)
maxima = (data == maximum_filter(data,10))
# How can I get only maxima, outstanding the background a certain value, let's say 500 ?
I'm afraid I don't really understand the scipy.ndimage.filters.maximum_filter()
function. Is there a way to obtain pixel-coordinates only within the spots and not within the background?
http://i.stack.imgur.com/RImHW.png (16-bit grayscale picture, 256*256 pixels)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…