Main Content


Convert CIE 1931 XYZ to RGB



RGB = xyz2rgb(XYZ) converts CIE 1931 XYZ values (2° observer) to sRGB values.


RGB = xyz2rgb(XYZ,Name,Value) specifies additional conversion options, such as the color space of the RGB image, using one or more name-value arguments.


collapse all

Convert a color value in the XYZ color space to the sRGB color space.

xyz2rgb([0.25 0.40 0.10])
ans = 1×3

    0.4174    0.7434    0.2152

Convert the color value in XYZ color space to the Adobe RGB (1998) color space.

xyz2rgb([0.25 0.40 0.10],'ColorSpace','adobe-rgb-1998')
ans = 1×3

    0.5323    0.7377    0.2730

Convert an XYZ color value to sRGB specifying the D50 whitepoint.

xyz2rgb([0.25 0.40 0.10],'WhitePoint','d50')
ans = 1×3

    0.3276    0.7517    0.2869

Convert an XYZ color value to an 8-bit encoded RGB color value.

xyz2rgb([0.25 0.40 0.10],'OutputType','uint8')
ans = 1x3 uint8 row vector

   106   190    55

Input Arguments

collapse all

XYZ color values to convert, specified as a numeric array in one of the following formats.

  • c-by-3 colormap. Each row specifies one XYZ color value.

  • m-by-n-by-3 image.

  • m-by-n-by-3-by-p stack of images.

Data Types: single | double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: rgb = xyz2rgb([0.25 0.40 0.10],ColorSpace="adobe-rgb-1998")

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: rgb = xyz2rgb([0.25 0.40 0.10],"ColorSpace","adobe-rgb-1998")

Color space of the output RGB values, specified as "srgb", "adobe-rgb-1998", "prophoto-rgb", or "linear-rgb". If you specify "linear-rgb", then xyz2rgb returns linearized sRGB values.

Data Types: string | char

Reference white point, specified as a 1-by-3 vector or one of the CIE standard illuminants listed in the table.

ValueWhite Point

CIE standard illuminant A, [1.0985, 1.0000, 0.3558]. Simulates typical, domestic, tungsten-filament lighting with correlated color temperature of 2856 K.

"c"CIE standard illuminant C, [0.9807, 1.0000, 1.1822]. Simulates average or north sky daylight with correlated color temperature of 6774 K. Deprecated by CIE.
"e"Equal-energy radiator, [1.000, 1.000, 1.000]. Useful as a theoretical reference.
"d50"CIE standard illuminant D50, [0.9642, 1.0000, 0.8251]. Simulates warm daylight at sunrise or sunset with correlated color temperature of 5003 K. Also known as horizon light.


CIE standard illuminant D55, [0.9568, 1.0000, 0.9214]. Simulates mid-morning or mid-afternoon daylight with correlated color temperature of 5500 K.

"d65"CIE standard illuminant D65, [0.9504, 1.0000, 1.0888]. Simulates noon daylight with correlated color temperature of 6504 K.
"icc"Profile Connection Space (PCS) illuminant used in ICC profiles. Approximation of [0.9642, 1.000, 0.8249] using fixed-point, signed, 32-bit numbers with 16 fractional bits. Actual value: [31595,32768, 27030]/32768.

Data Types: single | double | string | char

Data type of returned RGB values, specified as "double", "single", "uint8", or "uint16". If you do not specify OutputType, the output type is the same type as the input.

Data Types: string | char

Output Arguments

collapse all

Converted RGB color values, returned as a numeric array of the same size as the input. The output type is the same as the input type unless you specify the OutputType parameter.


  • If you specify the output RGB color space as "linear-rgb", then the output values are linearized sRGB values. If instead you want the output color space to be linearized Adobe RGB (1998), then you can use the rgb2lin function.

    For example, to convert CIE 1931 XYZ image XYZ to linearized Adobe RGB (1998) color space, perform the conversion in two steps:

    RGBadobe = xyz2rgb(XYZ,"ColorSpace","adobe-rgb-1998");
    RGBlinadobe = rgb2lin(RGBadobe,"ColorSpace","adobe-rgb-1998");

Version History

Introduced in R2014b

expand all