Colorize

Colorize[m]

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

Colorize[image]

replaces intensity values in image with pseudocolor values.

Details and Options

  • Colorize generates a pseudo or false coloring of 2D and 3D images to better visualize details in an image. It can also colorize an integer array, typically generated from a segmentation and clustering.
  • Colorize works with 2D and 3D images and integer arrays.
  • Colorize generates an 8-bit RGB image.
  • Colorize takes the following options:
  • ColorFunction Automatichow each pixel should be colored
    ColorFunctionScaling Truewhether to scale the argument to ColorFunction
    ColorRules Automaticrules for determining colors from matrix and pixel values
    ImageSize Automaticthe default displayed size of the image
  • By default, for images, "DarkRainbow" is used. Intensity values below 0 and above 1 are clipped.
  • For integer arrays, 0s and negative integer values are shown in black. Positive integers are colored using distinct colors for consecutive integers.
  • Use ColorFunctionfunc to specify a different color function. The function func maps scaled values between 0 and 1 to color values.
  • Use ColorFunctionScalingFalse to specify a color function on unscaled input values.
  • Supported ColorFunction settings include:
  • GrayLevelapply gray-level color space
    Hueapply HSB color space
    ColorData["scheme"]apply the specified ColorData function
    "scheme"equivalent to ColorData["scheme"]
    "GrayLevelOpacity"apply GrayLevel with Opacity; black values near 0 will be transparent, while white shades near 1 will be opaque
    "HueOpacity"apply Hue with Opacity
    "schemeOpacity"apply ColorData["scheme"] with Opacity
    "XRay"approximate an x-ray effect
    "WhiteBlackOpacity"apply a white-to-black color component with opacity
  • Use ColorRules to specify a list of color replacements. For arrays, color rules substitute integer values. For images, color rules are applied to grayscale values.
  • Colorize generates an RGB image of type "Byte". The image may have an alpha channel, depending on the input image, color function and color rules.

Examples

open allclose all

Basic Examples  (2)

Colorize a grayscale image:

Colorize a label matrix returned from a segmentation:

Scope  (5)

2D  (3)

Colorize an integer array:

Colorize a sparse array of integer values:

Colorize a grayscale image:

3D  (2)

Colorize a 3D label matrix:

Colorize a 3D grayscale image:

Options  (10)

ColorFunction  (4)

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:

A color function with opacity returns an image with an -channel:

ColorRules  (5)

Specify a background color different than black:

Replacing transparent colors results in an image with an -channel:

Specify color replacement rules for all matrix values:

Specify a color for the largest component:

Make the dark background transparent:

ImageSize  (1)

By default, ImageSize->Automatic is used:

Specify the image size:

Applications  (5)

Colorize result of a segmentation:

Pseudocoloring of an elevation map:

Colorize a CT scan to emphasize different tissue types:

A natural coloring scheme based on Hounsfield units (-1000 air, 0 water, ...):

Rescale CT data to Hounsfield units and colorize:

Random coloring of a map:

Colorize segmented countries based on their area:

Properties & Relations  (1)

Colorize a grayscale image using a neural network from the Wolfram Neural Net Repository:

Construct a net evaluate function:

Colorize a grayscale image:

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, https://reference.wolfram.com/language/ref/Colorize.html (updated 2012).

Text

Wolfram Research (2010), Colorize, Wolfram Language function, https://reference.wolfram.com/language/ref/Colorize.html (updated 2012).

CMS

Wolfram Language. 2010. "Colorize." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Colorize.html.

APA

Wolfram Language. (2010). Colorize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Colorize.html

BibTeX

@misc{reference.wolfram_2024_colorize, author="Wolfram Research", title="{Colorize}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Colorize.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_colorize, organization={Wolfram Research}, title={Colorize}, year={2012}, url={https://reference.wolfram.com/language/ref/Colorize.html}, note=[Accessed: 21-November-2024 ]}