本系列文章由 @yhl_leo 出品,转载请注明出处。
文章链接: http://blog.csdn.net/yhl_leo/article/details/52185581
PASCAL VOC图像分割数据集中,图像中各个类别以不同的颜色进行区分,即Ground Truth中,每种颜色都对应着相应的类别:
可以看出这个颜色表既好看又容易区分开。下面来看,这个color map是如何产生的。
先附上Matlab版本的代码:
% VOCLABELCOLORMAP Creates a label color map such that adjacent indices have different
% colors. Useful for reading and writing index images which contain large indices,
% by encoding them as RGB images.
%
% CMAP = VOCLABELCOLORMAP(N) creates a label color map with N entries.
function cmap = labelcolormap(N)
if nargin==0
N=256
end
cmap = zeros(N,3);
for i=1:N
id = i-1; r=0;g=0;b=