我正在做模板匹配 使用实现的函数在它们之间建立一个匹配空间,并获得原始照片中预期匹配的局部最大值
现在,我在列表中显示了局部最大点x,y
在我的GUI中,我想在局部极大值点周围画一个矩形或圆形 在检测到的图案标签中显示它们(原始图像的灰度以及检测到的形状上的矩形) 像这样
矩形和圆形的两个函数,当我已经在GUI中的标签上显示图像时,如何连接这两个函数以围绕局部极大值点绘制,从而获取局部极大值点并将其用作标签上显示图像上矩形的中心 除了这些功能与matplot,我希望他们在已经存在的GUI标签上的图像
def make_rects(plt_object,xy,template):
htemp, wtemp = template.shape
for ridx in range(xy.shape[0]):
y,x = xy[ridx]
r = plt.Rectangle((x-wtemp/2, y-htemp/2), wtemp, htemp, edgecolor='g', facecolor='none')
plt_object.add_patch(r)
def make_circles(plt_object,xy,template):
htemp, wtemp = template.shape
for ridx in range(xy.shape[0]):
y,x = xy[ridx]
plt_object.plot(x, y, 'o', markeredgecolor='g', markerfacecolor='none', markersize=10)
这是我实现的函数
import numpy as np
from scipy.signal import correlate2d
def match_template_corr(x, temp):
y = np.empty(x.shape)
y = correlate2d(x, temp, 'same')
return y
目前没有回答
相关问题 更多 >
编程相关推荐