Harris角点探测器
我想用python实现哈里斯角点检测器的方法,但我卡住了请给出一些建议。 我已经实现的方法可以找到HERE
/**
* {@inheritDoc}
*/
public function setDn($dn){
$this->dn = $dn;
}
/**
* {@inheritDoc}
*/
public function getDn(){
return $this->dn;
}
这是我想做的事情的例子:harris exempe
答案 0 :(得分:2)
def Harris():
if im == None:
msg.showerror('error', 'Ouvrire une image')
return 0
msg.showinfo('wait', 'Le programme traite l\'image, veuillez patienter')
global em
neim = imap1()
imarr = np.asarray(neim, dtype=np.float64)
ix = ndimage.sobel(imarr, 0)
iy = ndimage.sobel(imarr, 1)
ix2 = ix * ix
iy2 = iy * iy
ixy = ix * iy
ix2 = ndimage.gaussian_filter(ix2, sigma=2)
iy2 = ndimage.gaussian_filter(iy2, sigma=2)
ixy = ndimage.gaussian_filter(ixy, sigma=2)
c, l = imarr.shape
result = np.zeros((c, l))
r = np.zeros((c, l))
rmax = 0
for i in range(c):
print('loking for corner . . .')
for j in range(l):
print('test ', j)
m = np.array([[ix2[i, j], ixy[i, j]], [ixy[i, j], iy2[i, j]]], dtype=np.float64)
r[i, j] = np.linalg.det(m) - 0.04 * (np.power(np.trace(m), 2))
if r[i, j] > rmax:
rmax = r[i, j]
for i in range(c - 1):
print(". .")
for j in range(l - 1):
print('loking')
if r[i, j] > 0.01 * rmax and r[i, j] > r[i - 1, j - 1] and r[i, j] > r[i - 1, j + 1] \
and r[i, j] > r[i + 1, j - 1] and r[i, j] > r[i + 1, j + 1]:
result[i, j] = 1
result = np.transpose(result)
pc, pr = np.where(result == 1)
base = plt.gca().transData
rot = transforms.Affine2D().rotate_deg(270)
plt.plot(pr, pc, 'r', transform=rot + base, linestyle="None", marker="o", markersize=1)
plt.savefig('harris_test.png')
root_analy.geometry("1108x553+85+50")
frame_active.configure(width=1108, height=40)
# ---------- frame de present l'image filter------------------
frame_image_fil = Frame(root_analy)
frame_image_fil.configure(width=500, height=470)
frame_image_fil.place(x=605, y=42)
frame_image_fil.configure(borderwidth=2, relief=GROOVE)
# --------- frame de title de image resultat ---------------
frame_imgreslt = Frame(root_analy)
frame_imgreslt.configure(width=500, height=40, bg='#1B3F5D')
frame_imgreslt.place(x=760, y=512)
frame_imgreslt.configure(borderwidth=2, relief=GROOVE)
label_title1 = Label(frame_imgreslt, text='les point d\'intérêt', font=("Courier", 18), bg='#0F2130', foreground="#4F5459")
label_title1.pack()
img = open('harris_test.png')
em = img
img = img.resize((491, 458), ANTIALIAS)
img = ImageTk.PhotoImage(img)
pano = Label(frame_image_fil)
pano.configure(image=img)
pano.image = img
pano.place(x=0, y=0)
os.remove('harris_test.png')
return 0
答案 1 :(得分:0)