我跟着這個link的例子。但是,等高線從初始點收縮。是否有可能做出展開的輪廓?我想要顯示的圖像。左側的圖像是它的外觀,右側的圖像是我想要的樣子 - 展開而不是收縮。紅色圓圈是起點,藍色輪廓是在n次迭代之後。有沒有我可以設置的參數 - 我看了所有的參數,但似乎沒有設置。另外,當提到「活動輪廓」時,它通常是否假定輪廓收縮?我讀this paper,並認爲它可以合同和擴大。Scikit-image展開活動輪廓(蛇)
img = data.astronaut()
img = rgb2gray(img)
s = np.linspace(0, 2*np.pi, 400)
x = 220 + 100*np.cos(s)
y = 100 + 100*np.sin(s)
init = np.array([x, y]).T
if not new_scipy:
print('You are using an old version of scipy. '
'Active contours is implemented for scipy versions '
'0.14.0 and above.')
if new_scipy:
snake = active_contour(gaussian(img, 3),
init, alpha=0.015, beta=10, gamma=0.001)
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111)
plt.gray()
ax.imshow(img)
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])
您可以嘗試將max_px_move設置爲-1,但我不知道這是否可行。 –