Function File: label2rgb (L)
Function File: label2rgb (L, cmap)
Function File: label2rgb (L, cmap, background)
Function File: label2rgb (L, cmap, background, order)

Convert labeled image into RGB.

The labeled image L is converted into an RGB image using the colormap cmap. The label number of each region is used to select the color from cmap which can be specified as:

  • N-by-3 colormap matrix where N must be larger than or equal to the highest label number;
  • name of a function that returns a colormap;
  • handle for a function that returns a colormap (defaults to jet).

In a labeled image, zero valued pixels are considered background and are colored according to the color background. It can be specified as an RGB triplet values (3 element vector of values between 0 and 1), or by name:

  • "w" or "white" (default)
  • "b" or "blue".
  • "c" or "cyan".
  • "g" or "green".
  • "k" or "black".
  • "m" or "magenta".
  • "r" or "red".
  • "y" or "yellow".

The option order must be a string with values "shuffle" or "noshuffle" (default). If shuffled, the colors in cmap are permuted randomly before the image conversion.

The output RGB image is always of class uint8.

See also: bwconncomp, bwlabel, colormap, ind2rgb.

Package: image