Paint a mask with its colormap

Description

Paint a mask with its colormap

Usage

classes_to_colours(mask, colormap)

Arguments

mask Class indices, counted from 1: a height x width matrix, or an image x height x width array for several at once.
colormap A list of RGB triples, one per class; see binary_colormap.

Value

The same shape with a trailing RGB axis, values 0-255.

Examples

library("rplatypus")

mask <- matrix(c(1, 1, 2, 2), nrow = 2)
dim(classes_to_colours(mask, binary_colormap))
[1] 2 2 3