ColorConvert

ColorConvert[expr, colspace]
converts color specifications in expr to refer to the color space represented by colspace.

Details and OptionsDetails and Options

  • The expression expr can be a color specification such as RGBColor[...] or Red, an Image object, or an explicit list of color channel values.
  • ColorConvert[list, ...] by default interprets list as follows:
  • {v}gray level
    {v,a}gray level and parameter
    {r,g,b}red, green, blue levels
    {r,g,b,a}RGB with parameter
  • Color spaces supported by ColorConvert include:
  • "Grayscale"gray level
    "RGB"red, green, blue
    "CMYK"cyan, magenta, yellow, black
    "HSB"hue, saturation, brightness
    "XYZ"CIE XYZ
    "LAB"CIE Lab
    "LUV"CIE Luv
    ColorProfileData[...][i]color profile with the specified rendering intent i
  • Luminance value in and color spaces by standard ranges from 0 to 100. When converting to these color spaces, values of all channels are divided by 100 so that values for the L channel fall between 0 and 1. The two color channels can have values outside the range 0 to 1.
  • When converting to any CIE color spaces, ColorConvert returns an image of a real type.
  • With the option setting ColorSpace->src, ColorConvert[list, ...] interprets channel values in list according to the color space src.
  • 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.
  • ColorConvert also works with Image3D objects.

ExamplesExamplesopen allclose all

Basic Examples (5)Basic Examples (5)

Convert a color photo to grayscale:

In[1]:=
Click for copyable input
Out[1]=

Convert to CMYK:

In[1]:=
Click for copyable input
Out[1]=

This shows that the previous output is a CMYK image:

In[2]:=
Click for copyable input
Out[2]=

Convert an RGB color object to CMYK:

In[1]:=
Click for copyable input
Out[1]=

Convert an intensity value to RGB:

In[1]:=
Click for copyable input
Out[1]=

Convert an RGB color object to HSB:

In[1]:=
Click for copyable input
Out[1]=
New in 7 | Last modified in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »