I'm working on template matching Using implemented function to make a match space between them and getting local maxima of the expected matches in the original photo
now, I have the local maxima points x , y displayed in a list
in my GUI I want to draw a rectangle or a circle around the point of local maxima displaying them in the detected pattern label (grayscale of original image with the rectangle on the detected shape) like this
two functions for rectangle and circle, how can i connect those two functions to be drawn around the point of local maxima when i already display an image on the label in the GUI, such that the local maxima point is taken and used to be the center of the rectangle on the displayed image on label except those functions are with matplot i want them on already existing image on label in 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)
Here is my implemented function
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