训练深度图的图像转换

在很多应用中,需要使用深度图进行模型训练,一般操作是将深度图转为彩色图进行训练。

Matlab函数:label2rgb(),转换标记矩阵到RGB图像

参考网址:https://in.mathworks.com/help/images/ref/label2rgb.html

语法:

RGB = label2rgb(L)

RGB = label2rgb(L,cmap)

RGB = label2rgb(L,cmap,zerocolor)

RGB = label2rgb(L,cmap,zerocolor,order)

1)RGB = label2rgb(L) 

输入:L——标记矩阵(可由labelmatrix, bwlabel, bwlabeln, watershed返回) 

输出:RGB——彩色图像

注:根据L的数值对应,默认对应到colormap(jet)的色彩,返回RGB矩阵 

2)RGB = label2rgb(L, map)

输入:L——标记矩阵(可由labelmatrix, bwlabel, bwlabeln, watershed返回)、map——颜色映射表 

输出:RGB——彩色图像

注:map为n*3的矩阵,可以通过MATLAB的colormap函数来返回,比如colormap('jet')等。也可以根据要求自己定义。默认为colormap(jet)。 

3)RGB = label2rgb(L, map, zerocolor) 

defines the RGB color of the elements labeled 0 (zero) in the input label matrix L. As the value of zerocolor, specify an RGB triple or one of the strings listed in this table.

输入:L——标记矩阵(可由labelmatrix, bwlabel, bwlabeln, watershed返回)

            map——颜色映射表

            zerocolor——对应于标记0的颜色 

输出:RGB——彩色图像 

注:zerocolor可以取值如下表,默认为[1 1 1],即白色。 

 Value

Color 

 'b'

 蓝色

 'c'

 蓝绿色

 'g'

 绿色

 'k'

 黑色

 'm'

 洋红色

 'r'

 红色

 'w'

 白色

'y' 

 黄色

4)RGB = label2rgb(L, map, zerocolor, order) 

输入:L——标记矩阵(可由labelmatrix, bwlabel, bwlabeln, watershed返回)

            map——颜色映射表

            zerocolor——对应于标记0的颜色

            order——标记矩阵和颜色映射表对应方式
输出:RGB——彩色图像 

注:order默认为noshuffle,即根据L的数值来对应颜色。另外可以取值为shuffle,说明使用伪随机方式来对应。

发布了191 篇原创文章 · 获赞 104 · 访问量 34万+

猜你喜欢

转载自blog.csdn.net/u013925378/article/details/102698342