main Content

label2rgb

将标签矩阵转换为RGB图像

Description

例子

RGB= label2rgb(lConverts a label image,l进入RGB颜色图像,目的是可视化标记区域。这label2rgbfunction determines the color to assign to each object based on the number of objects in the label matrix. Thelabel2rgb功能从整个Colormap的范围中挑选颜色。

RGB= label2rgb(l,,,,cmapspecifies the colormapcmapto be used in the RGB image.

RGB= label2rgb(l,,,,cmap,,,,zerocolor指定背景元素的RGB颜色(标记为像素0)。

RGB= label2rgb(l,,,,cmap,,,,zerocolor,,,,命令Controls howlabel2rgb将颜色分配给标签矩阵中的区域。

RGB= label2rgb(___,,,,'OutputFormat',outputFormatenables you to specify that the function return a list of unique colors instead of an RGB image.

Examples

全部收缩

Read an image and display it.

i = imread('rice.png');imshow(i)

图包含一个轴对象。轴对象包含类型图像的对象。

从图像创建标签矩阵。

bw = imbinarize(i);cc = bwconncomp(bw);L = LabelMatrix(CC);

使用默认设置将标签矩阵转换为RGB图像。

rgb = label2rgb(l);图IMShow(RGB)

图包含一个轴对象。轴对象包含类型图像的对象。

将标签矩阵转换为RGB图像,指定可选参数。此示例使用'spring'colormap,将背景像素设置为颜色青色,并随机将颜色分配给标签。

rgb2 = label2rgb(l,'spring',,,,'C',,,,“洗牌”);图IMShow(RGB2)

图包含一个轴对象。轴对象包含类型图像的对象。

输入参数

全部收缩

连续区域的标签图像,指定为以下一个。

  • 非负整数的矩阵。标记的像素0are the background. Pixels labeled1组成一个对象;标记的像素2组成第二个对象;等等。您可以从标签函数中获得数字标签图像,例如分水岭orLabelMatrix

  • 一个分类矩阵。

数据类型:单身的|双倍的|int8|int16|int32|INT64|UINT8|uint16|UINT32|Uint64|逻辑|Categorical

用于生成的颜色图像中的colormapRGB,指定为以下内容之一。

Value

Description
C-by-3矩阵of data type双倍的

colormap矩阵指定CColors, each as an RGB triple.C必须大于或等于标签的数量,数字,,,,in label matrixl。您可以计算标签的数量为数字= max(L(:))

IfC是greater than数字, 然后label2rgb创建RGBimage using only the first数字rows in the matrix.

结肠功能

matlab的名称®结肠功能,例如'喷射'or'灰色的'。SeeColormap有关支持的菌落清单。万博1manbetx

结肠手柄

colormap功能的手柄,例如@喷射or@灰色的

填充颜​​色,指定为代表RGB三重或数字标签图像的以下颜色缩写之一的3元素矢量。label2rgb将填充颜色应用于标签0用于数字标签图像或标签用于分类标签图像。

Value

颜色

'b' 蓝色的
'C' Cyan
'G' 绿
'k' 黑色的
'm' 品红
'r' 红色的
'W' 白色的
'y' Yellow

颜色顺序,,,,specified as'noshuffle'or“洗牌”。这'noshuffle'Order以数值顺序将Colormap颜色安排到标签矩阵区域。这“洗牌”命令assigns colormap colors pseudorandomly.

返回的RGB数据的输出格式RGB,指定为以下内容之一。

  • 'image'-Return an RGB image. If the size of the input label matrixlm-by-n, 然后the size of the output RGB image ism-by-n-by-3.

  • “三胞胎”-Return a list of RGB colors. The size of the output is aC-by-3矩阵,每个矩阵包含一个RGB三胞胎C输入标签矩阵中的标签。

输出参数

全部收缩

RGBdata, returned as an numeric matrix.

数据类型:UINT8

扩展功能

Introduced before R2006a