generates an image from an integer matrix m, using colors for positive integers and black for non-positive integers.


replaces intensity values in image with pseudocolor values.

Details and Options


open allclose all

Basic Examples  (3)

Colorize a grayscale image:

Colorize a label matrix returned from a segmentation:

Colorize a 3D label matrix:

Options  (7)

ColorFunction  (3)

Apply a color scheme to a map:

Colorize a grayscale image:

Keep the background black using ColorRules:

Use a pure function as the color function:

ColorRules  (3)

Specify a background color different than black:

Specify color replacement rules for all matrix values:

Specify a color for the largest component:

ImageSize  (1)

By default, ImageSize->Automatic is used:

Specify the image size:

Applications  (3)

Pseudocoloring of an elevation map:

Random coloring of a map:

Colorize segmented countries based on their area:

Possible Issues  (1)

All foreground pixels are colored the same in a binary image:

To highlight components using different colors, compute the connected components first:

Neat Examples  (2)

Random colors applied to connected components of a cellular automaton:

Running more steps of the cellular automaton:

Colorize components in a 3D cellular automaton:

Wolfram Research (2010), Colorize, Wolfram Language function, (updated 2012).


Wolfram Research (2010), Colorize, Wolfram Language function, (updated 2012).


@misc{reference.wolfram_2020_colorize, author="Wolfram Research", title="{Colorize}", year="2012", howpublished="\url{}", note=[Accessed: 18-January-2021 ]}


@online{reference.wolfram_2020_colorize, organization={Wolfram Research}, title={Colorize}, year={2012}, url={}, note=[Accessed: 18-January-2021 ]}


Wolfram Language. 2010. "Colorize." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012.


Wolfram Language. (2010). Colorize. Wolfram Language & System Documentation Center. Retrieved from