ColorConvert

ColorConvert[image,colspace]

converts the color space of image to the specified color space colspace.

ColorConvert[color,colspace]

converts color specifications of a color directive.

Details

  • ColorConvert is typically used to change the color specification of an image. Color spaces are used for different purposes, e.g. CMYK is typically used in printing and Lab is used for color comparison.
  • ColorConvert works with colors and arbitrary 2D and 3D images, as well as an explicit list of color channel values.
  • ColorConvert[list,] by default interprets list as follows:
  • {v}gray level
    {v,α}gray level and alpha parameter
    {r,g,b}red, green, blue levels
    {r,g,b,α}RGB with alpha parameter
  • Supported color spaces colspace include:
  • "Grayscale"GrayLevel
    "RGB"RGBColor
    "CMYK"CMYKColor
    "HSB"Hue
    "XYZ"XYZColor
    "LAB"LABColor
    "LCH"LCHColor
    "LUV"LUVColor
    ColorProfileData[][i]color profile with the specified rendering intent i
  • When converting to or from "Grayscale", "RGB", "CMYK", and "HSB", channel values are clipped to be between 0 and 1.
  • When converting to and from "XYZ", "LAB", "LUV", and "LCH", channel values are not clipped and when applied to images will result in an image of a real type.
  • ColorConvert automatically performs chromatic (white point) adaptation. D50 white point is assumed for "XYZ", "LAB", "LUV", and "LCH" and D65 for "RGB", "CMYK", "HSB", and "Grayscale".
  • When converting to and from "RGB", the channel values are assumed to be in the sRGB color space.
  • ColorConvert[input,src->dst] can be used to convert to the color space specified by dst, while interpreting channel values in input according to the color space src. Both src and dst can be either a known color space or a color profile.
  • ColorConvert[image,colspace] is equivalent to ColorConvert[image,ImageColorSpace[image]->colspace].
  • Color space specified by src should be compatible with the number of channels in image.
  • If dst is a color profile, one of the device or connection spaces should match the color space of the input or a specified source color space src.

Examples

open allclose all

Basic Examples  (3)

Convert a color photo to grayscale:

Convert to CMYK:

This shows that the previous output is a CMYK image:

Convert an RGB color object to CMYK:

Scope  (9)

Convert an intensity value to grayscale:

Convert an intensity value to RGB:

Convert out-of-range values:

Convert RGB intensity values to CMYK:

Convert a color to another color space:

Convert a list of colors:

Convert a grayscale image to RGB:

Convert from a known color space to Lab:

Specify the color space for the image with an unknown color space and convert to RGB:

Convert a list of images:

Use a color profile to convert to the sRGB version 4 color space:

Specify device profiles for both source and destination:

Specify the rendering intent:

Convert a 3D image to LCh:

Applications  (2)

Convert an image to its "LAB" representation and perform custom color negations:

Convert an image to the "LCH" color model to perform specific chroma and hue transformations:

Segment out the three strawberries in the image:

Transform the colors in each image segment and combine the results:

Properties & Relations  (2)

When the destination is specified with a ColorProfileData, the result is in the device color space:

The grayscale representation of an RGB color is equivalent to the luma in the Y'CbCr color model:

Possible Issues  (1)

Conversion using a color profile may result in an approximate color representation:

In such cases converting back to the original color space gives a different color:

This difference may become significant after several conversion steps:

Built-in conversions between RGB and CMYK preserve the color:

Wolfram Research (2008), ColorConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorConvert.html (updated 2014).

Text

Wolfram Research (2008), ColorConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorConvert.html (updated 2014).

BibTeX

@misc{reference.wolfram_2021_colorconvert, author="Wolfram Research", title="{ColorConvert}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/ColorConvert.html}", note=[Accessed: 02-August-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_colorconvert, organization={Wolfram Research}, title={ColorConvert}, year={2014}, url={https://reference.wolfram.com/language/ref/ColorConvert.html}, note=[Accessed: 02-August-2021 ]}

CMS

Wolfram Language. 2008. "ColorConvert." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/ColorConvert.html.

APA

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