Xol*_*lve 6 python numpy image-processing scipy
我正在尝试使用NumPy和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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1097 次 |
最近记录: |