Learn R Programming

colorSpec (version 1.5-0)

standardRGB: Convert from XYZ to some standard RGB spaces

Description

To display an XYZ value, it typically must be converted to a standard RGB space. This is the function to do it.

Usage

RGBfromXYZ( XYZ, space )

Value

An Mx3 matrix where M is the number of rows in XYZ, or M=1 if XYZ is a 3-vector. Each row of the returned matrix is filled with linear RGB in the appropriate RGB space. Values outside the unit cube are not clamped. To compute non-linear display RGB, see DisplayRGBfromLinearRGB().

In case of error the function returns NULL.

Arguments

XYZ

a 3-vector, or a matrix with 3 columns with XYZs in the rows

space

the name of the RGB space - either 'sRGB' or 'Adobe RGB'. The match is case-insensitive, and spaces in the string are ignored.

WARNING

This function is deprecated. New software should use spacesRGB::RGBfromXYZ() instead. The new function returns "signal RGB" instead of linear RGB.

Details

The input XYZ is multiplied by the appropriate 3x3 conversion matrix (for sRGB or Adobe RGB). These matrices are taken from Lindbloom and not from the corresponding Wikipedia articles; for the reason why see Note.

See Also

D65, officialXYZ, DisplayRGBfromLinearRGB

Examples

Run this code
RGBfromXYZ( officialXYZ('D65'), 'sRGB' )
#      R G B
# [1,] 1 1 1    # not really 1s, but difference < 1.e-7

RGBfromXYZ( c(.3127,0.3290,0.3583)/0.3290, 'sRGB' )
#              R        G       B
# [1,] 0.9998409 1.000023 1.00024    difference > 1.e-5

Run the code above in your browser using DataLab