für eine Kantendetektion möchte ich das "Active Contour Model" verwenden.
folgenden Programmcode habe ich dazu gefunden.
Code: Alles auswählen
img=cv2.imread("1.4301_20x_dunkel.png",0)
plt.imshow(img)
rows , cols=img.shape
s = np.linspace(0, 2*np.pi, 400)
x = 1250 +100*np.cos(s)
y = 750 + 100*np.sin(s)
init = np.array([x, y]).T
snake = active_contour(gaussian(img, 3),
init, alpha=-0.015, beta=10, gamma=0.001)
fig, ax = plt.subplots(figsize=(7, 7))
ax.imshow(img, cmap=plt.cm.gray)
ax.plot(init[:, 0], init[:, 1], '--r', lw=3)
ax.plot(snake[:, 0], snake[:, 1], '-b', lw=3)
ax.set_xticks([]), ax.set_yticks([])
ax.axis([0, img.shape[1], img.shape[0], 0])
Das Problem an diesem Beispiel ist, dass es die Kanten in einem Kreis sucht. Für meine Anwendung benötige ich allerdings eine Ellipse und eine Rechteck.
Leider finde ich dazu nichts passendes.
Vielen Dank für eure Hilfe