ColorConvert

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

DetailsDetails

  • The expression expr can be a color specification such as RGBColor[] or Red, an Image or Image3D object, or an explicit list of color channel values.
  • ColorConvert[list,] by default interprets list as follows:
  • {v}gray level
    {v,α}gray level and parameter
    {r,g,b}red, green, blue levels
    {r,g,b,α}RGB with parameter
  • Color spaces supported by ColorConvert 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 , , , and , channel values are clipped to be between 0 and 1.
  • When converting to and from , , , and , 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 , , , and and D65 for , , , and .
  • When converting to and from , 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.

ExamplesExamplesopen allclose all

Basic Examples  (6)Basic Examples  (6)

Convert a color photo to grayscale:

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

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 a 3D image to LCh:

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

Convert an RGB color object to CMYK:

Convert an intensity value to RGB:

Convert an RGB color object to HSB:

Introduced in 2008
(7.0)
| Updated in 2014
(10.0)