用法:
cucim.skimage.segmentation.relabel_sequential(label_field, offset=1)
將任意標簽重新標記為 {
offset
, ...offset
+ number_of_labels}。此函數還返回正向映射(將原始標簽映射到縮減標簽)和反向映射(將縮減標簽映射回原始標簽)。
- label_field:numpy int 數組,任意形狀
標簽數組,必須是非負整數。
- offset:整數,可選
返回標簽將從
offset
開始,這應該是嚴格的正數。
- relabeled:int的numpy數組,與
label_field
相同的形狀 標簽映射到 {offset, ..., number_of_labels + offset - 1} 的輸入標簽字段。數據類型將與
label_field
相同,除非 offset + number_of_labels 導致當前數據類型溢出。- forward_map:數組映射
從原始標簽空間到返回標簽空間的映射。可用於重新應用相同的映射。請參閱使用示例。輸出數據類型將與
relabeled
相同。- inverse_map:數組映射
從新標簽空間到原始空間的映射。這可用於從重新標記的標簽字段中重建原始標簽字段。輸出數據類型將與
label_field
相同。
- relabeled:int的numpy數組,與
參數:
返回:
注意:
假定標簽 0 表示背景並且從不重新映射。
對於某些輸入,前向映射可能非常大,因為它的長度由標簽字段的最大值給出。然而,在大多數情況下,
label_field.max()
比label_field.size
小得多,在這些情況下,前向映射保證小於輸入或輸出圖像。例子:
>>> import cupy as cp >>> from cucim.skimage.segmentation import relabel_sequential >>> label_field = cp.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 >>> cp.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]) >>> cp.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 cucim.skimage.segmentation.random_walker用法及代碼示例
- Python cucim.skimage.segmentation.find_boundaries用法及代碼示例
- Python cucim.skimage.segmentation.join_segmentations用法及代碼示例
- Python cucim.skimage.feature.shape_index用法及代碼示例
- Python cucim.skimage.restoration.richardson_lucy用法及代碼示例
- Python cucim.skimage.util.invert用法及代碼示例
- Python cucim.skimage.data.binary_blobs用法及代碼示例
- Python cucim.skimage.filters.roberts_neg_diag用法及代碼示例
- Python cucim.skimage.color.lch2lab用法及代碼示例
- Python cucim.skimage.measure.label用法及代碼示例
- Python cucim.skimage.color.rgb2gray用法及代碼示例
- Python cucim.skimage.filters.gabor用法及代碼示例
- Python cucim.skimage.transform.rescale用法及代碼示例
- Python cucim.skimage.filters.roberts_pos_diag用法及代碼示例
- Python cucim.skimage.filters.roberts用法及代碼示例
- Python cucim.skimage.morphology.dilation用法及代碼示例
- Python cucim.skimage.feature.corner_foerstner用法及代碼示例
- Python cucim.skimage.measure.moments_coords用法及代碼示例
- Python cucim.skimage.filters.gabor_kernel用法及代碼示例
- Python cucim.skimage.color.hsv2rgb用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cucim.skimage.segmentation.relabel_sequential。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。