簡體   English   中英

為什么當我的種子點與我要填充的容器一樣大時,來自 scikit-image 的分水嶺 function 不起作用

[英]Why do watershed function from scikit-image does not work when my seed points are exactly as large as the vessels I want to fill

好的,情況就是這樣,我想為這個二進制船只圖像制作一個分水嶺。

二元血管

我想將這些彩色血管用作算法的種子點。

種子點

似乎當我使用原始彩色圖像時,分水嶺不會比彩色圖像更遠。

目標是擁有這個形象。 填充二元容器

代碼使用的是這個

distances = distance_transform_edt(vessels)
segmentation = watershed(-distances, markers, mask=vessels).

我發現的唯一解決方案是侵蝕標記數據(第一張彩色圖像)。

你們有解決方案為什么分水嶺這樣做嗎? 我們甚至在其他計算機上嘗試了相同的代碼,它可以在沒有腐蝕的情況下工作。

編輯:

這是距離的圖像。 當我取負數時,每1變成-1。 所以圖像中的最大值變為0。

距離圖像

歡迎來到 SO 的 scikit-image 線程。 下面是一個可重復的小示例,表明即使使用接觸標記,流域也表現良好。

import matplotlib.pyplot as plt
import numpy as np
from skimage import segmentation
from scipy import ndimage

img = np.zeros((20, 20), dtype=np.bool)
img[3:-3, 3:-3] = True

distance = ndimage.distance_transform_edt(img)

markers = np.zeros_like(img, dtype=np.uint8)
markers[7:-7, 5:10] = 1
markers[7:-7, 10:15] = 2

ws = segmentation.watershed(-distance, markers, mask=img)
fig, ax = plt.subplots(1, 3)
ax[0].imshow(img)
ax[1].imshow(markers)
ax[2].imshow(ws)
plt.show()

您的標記數組中未標記的血管像素是否設置為 0 而是設置為 1? 分水嶺僅標記 0 值像素。

一個可重現的獨立腳本可能會有所幫助,您鏈接到的不同圖像具有不同的尺寸,因此很難使用它們。

最后,您可能有興趣嘗試隨機游走算法,該算法可以為您的圖像產生非常好的結果(在您想要分離的區域之間沒有強梯度)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM