我正在尝试使用进行图像处理NumPy http://en.wikipedia.org/wiki/NumPy and scipy http://en.wikipedia.org/wiki/SciPy。我有一个对应于背景的模板图像,我想找出它在输入图像中出现的所有位置,并将输出中相应的数组位置设置为 1,否则将它们设置为 0。我该怎么做?
您可以使用 scipy.ndimage.correlate 将模板与图像相关联。然后寻找能为您提供匹配的亮点。例子:
import scipy.ndimage
from numpy import mean, std
# a, b contain image and template in numpy arrays
correlation = scipy.ndimage.correlate(a, b)
matches = (correlation-mean(correlation)) > 5*std(correlation) # tune depending on level of noise
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)