2017-08-17 134 views
0

我跟着這個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]) 

enter image description here

+0

您可以嘗試將max_px_move設置爲-1,但我不知道這是否可行。 –

回答

0

如果你看看Scikit active contour你看,你有以下參數:

w_line - 控制吸引力的亮度。使用負值吸引到黑暗區域

因此,在您的問題,你想擴大到黑暗的邊緣,因此我認爲你應該使用負面的w_line。

+0

我試圖這樣做,但似乎我正在使用一個完全錯誤的算法開始。 – matchifang

+0

您是否嘗試過更清潔該區域?去噪?一些形態學操作去除穿過該區域的白線? –