用法:
skimage.segmentation.relabel_sequential(label_field, offset=1)
將任意標簽重新標記為 {offset, ... offset + number_of_labels}。
此函數還返回正向映射(將原始標簽映射到縮減標簽)和反向映射(將縮減標簽映射回原始標簽)。
- label_field:int任意形狀的numpy數組
標簽數組,必須是非負整數。
- offset:int 可選
返回標簽將從偏移量開始,這應該是嚴格的正數。
- relabeled:int 的 numpy 數組與label_field
標簽映射到 {offset, ..., number_of_labels + offset - 1} 的輸入標簽字段。數據類型將與label_field 相同,除非偏移量+number_of_labels 導致當前數據類型溢出。
- forward_map:ArrayMap
從原始標簽空間到返回標簽空間的映射。可用於重新應用相同的映射。請參閱使用示例。輸出數據類型將與重新標記的相同。
- inverse_map:ArrayMap
從新標簽空間到原始空間的映射。這可用於從重新標記的標簽字段中重建原始標簽字段。輸出數據類型將與label_field 相同。
參數:
返回:
注意:
假定標簽 0 表示背景並且從不重新映射。
對於某些輸入,前向映射可能非常大,因為它的長度由標簽字段的最大值給出。然而,在大多數情況下,
label_field.max()
比label_field.size
小得多,在這些情況下,前向映射保證小於輸入或輸出圖像。例子:
>>> from skimage.segmentation import relabel_sequential >>> label_field = np.array([1, 1, 5, 5, 8, 99, 42]) >>> relab, fw, inv = relabel_sequential(label_field) >>> relab array([1, 1, 2, 2, 3, 5, 4]) >>> print(fw) ArrayMap: 1 → 1 5 → 2 8 → 3 42 → 4 99 → 5 >>> np.array(fw) array([0, 1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) >>> np.array(inv) array([ 0, 1, 5, 8, 42, 99]) >>> (fw[label_field] == relab).all() True >>> (inv[relab] == label_field).all() True >>> relab, fw, inv = relabel_sequential(label_field, offset=5) >>> relab array([5, 5, 6, 6, 7, 9, 8])
相關用法
- Python skimage.segmentation.random_walker用法及代碼示例
- Python skimage.segmentation.active_contour用法及代碼示例
- Python skimage.segmentation.flood_fill用法及代碼示例
- Python skimage.segmentation.clear_border用法及代碼示例
- Python skimage.segmentation.felzenszwalb用法及代碼示例
- Python skimage.segmentation.watershed用法及代碼示例
- Python skimage.segmentation.expand_labels用法及代碼示例
- Python skimage.segmentation.find_boundaries用法及代碼示例
- 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.relabel_sequential。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。