skimage 中 color.label2rgb 的输出

the output of color.label2rgb in skimage

normalized cut code segment中,我不是很清楚color.label2rgb.

的输出
labels1 = segmentation.slic(img, compactness=30, n_segments=400)
out1 = color.label2rgb(labels1, img, kind='avg')

当我输出labels1的结果和out1的不同维度时,看起来像out1的结果labels1 中的条目值不匹配。 out1中输入值的含义是什么?它们与 labels1 中的标签 ID 有什么关系?

segmentation.slic 将在 Color-(x,y,z) space.

中使用 k-means 聚类对图像进行分割

np.unique(labels1) 会给你标签。


接下来,color.label2rgbreturns RGB 图像,其中在图像上绘制了颜色编码标签。

out1.shape returns (400, 600, 3) 这是将标签中每个不同值的循环颜色图(颜色)与图像以特定 alpha 值混合的结果.

此外,color.label2rgb 中有一个名为 kind 的默认输入参数。

The kind of color image desired. ‘overlay’ cycles over defined colors and overlays the colored labels over the original image. ‘avg’ replaces each labeled segment with its average color, for a stained-class or pastel painting appearance.

因此,在您的情况下,您将每个标记的片段替换为其平均颜色,以获得染色 class 或粉彩画的外观。