python - 模板匹配 - 在 GUI 上匹配绘制形状
问题描述
我正在研究模板匹配使用实现的功能在它们之间建立匹配空间并获得原始照片中预期匹配的局部最大值
现在,我将局部最大值 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
解决方案
推荐阅读
- python - How to avoid execution of Python UnitTest method "addCleanup" after test case failure?
- r - 在 data.table 中创建新列时如何引用整行?
- c# - 调用 RetrieveOrganizationInfoRequest 时出现 NetDispatcherFaultException
- ios - How to disable a user's ability to select text in a UITextField or UITextView?
- c# - Button Click without any ID C# Webbrowser
- javascript - 如何在 TestCafe 的通用属性中使用/打印值
- r - 迭代数天并获取价格信息
- c# - ReSharper / Visual Studio 添加
所有未记录的继承函数和属性 - r - 我想将 essemble id 与数据匹配,并希望使用 R 将其替换为相应的 id
- c# - 如何在文件中序列化所有流