用法:
skimage.segmentation.expand_labels(label_image, distance=1)
通過
distance
像素展開標簽圖像中的標簽而不重疊。給定一個標簽圖像,
expand_labels
將標簽區域(連接的組件)向外增長最多distance
個像素,而不會溢出到相鄰區域。更具體地說,每個在歐幾裏得距離 distance 像素的歐幾裏得距離內的每個背景像素都被分配了該連接分量的標簽。當多個連通分量在背景像素的distance
像素內時,將分配最近連通分量的標簽值(有關多個標簽等距離的情況,請參見注釋)。- label_image:dtype int的ndarray
標簽圖像
- distance:浮點數
以像素為單位的歐幾裏得距離,用於增長標簽。默認為一。
- enlarged_labels:dtype int的ndarray
標記數組,其中所有連接區域都已放大
參數:
返回:
注意:
在標簽間隔超過
distance
像素的情況下,這相當於使用半徑為distance
的圓盤或超球進行形態膨脹。然而,與形態擴張相反,expand_labels
不會將標簽區域擴展到相鄰區域。expand_labels
的這個實現是從 CellProfiler [1] 派生的,它被稱為模塊“IdentifySecondaryObjects (Distance-N)”[2]。當一個像素到多個區域的距離相同時,存在一個重要的邊情況,因為沒有定義哪個區域擴展到該空間。在這裏,確切的行為取決於
scipy.ndimage.distance_transform_edt
的上遊實現。參考:
例子:
>>> labels = np.array([0, 1, 0, 0, 0, 0, 2]) >>> expand_labels(labels, distance=1) array([1, 1, 1, 0, 0, 2, 2])
標簽不會相互覆蓋:
>>> expand_labels(labels, distance=3) array([1, 1, 1, 1, 2, 2, 2])
在平局的情況下,行為未定義,但目前按字典順序解析為最接近
(0,) * ndim
的標簽。>>> labels_tied = np.array([0, 1, 0, 2, 0]) >>> expand_labels(labels_tied, 1) array([1, 1, 1, 2, 2]) >>> labels2d = np.array( ... [[0, 1, 0, 0], ... [2, 0, 0, 0], ... [0, 3, 0, 0]] ... ) >>> expand_labels(labels2d, 1) array([[2, 1, 1, 0], [2, 2, 0, 0], [2, 3, 3, 0]])
相關用法
- Python skimage.segmentation.active_contour用法及代碼示例
- Python skimage.segmentation.relabel_sequential用法及代碼示例
- Python skimage.segmentation.flood_fill用法及代碼示例
- Python skimage.segmentation.clear_border用法及代碼示例
- Python skimage.segmentation.felzenszwalb用法及代碼示例
- Python skimage.segmentation.watershed用法及代碼示例
- Python skimage.segmentation.find_boundaries用法及代碼示例
- Python skimage.segmentation.random_walker用法及代碼示例
- Python skimage.segmentation.slic用法及代碼示例
- Python skimage.segmentation.flood用法及代碼示例
- Python skimage.segmentation.join_segmentations用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.color.lab2lch用法及代碼示例
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
- Python skimage.feature.blob_dog用法及代碼示例
- Python skimage.filters.unsharp_mask用法及代碼示例
- Python skimage.registration.optical_flow_tvl1用法及代碼示例
- Python skimage.filters.rank.noise_filter用法及代碼示例
- Python skimage.exposure.histogram用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.segmentation.expand_labels。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。