Learn R Programming

spacesRGB (version 1.1-1)

Signal RGB Calculation: Convert XYZ or Linear RGB to Signal RGB

Description

Convert XYZ or Linear RGB to Signal RGB, multiple RGB spaces are available

Usage

RGBfromXYZ( XYZ, space='sRGB', which='scene', TF=NULL, maxSignal=1 ) 

SignalRGBfromLinearRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )

Arguments

XYZ

a numeric Nx3 matrix with CIE XYZ coordinates in the rows, or a vector that can be converted to such a matrix, by row. The XYZ are assumed to be viewed under the white-point of the given RGB space.

RGB

a numeric Nx3 matrix with linear RGB coordinates in the rows, or a vector that can be converted to such a matrix, by row. The RGB are assumed normalized to the unit cube, but are allowed to be outside it.

space

the name of an installed RGB space. The name matching is partial and case-insensitive.

which

the input linear RGB - either 'scene' or 'display'. Usually the OOTF for the space is the identity and so these two are the same.

TF

if not NULL, TF overrides the appropriate transfer function of space. TF can be a positive number, or function that takes the interval [0,1] to itself. If TF=1, the output RGB values are actually linear, and not clamped (see Value). If TF is not NULL in SignalRGBfromLinearRGB(), then space and which are ignored.

maxSignal

maximum value of non-linear RGB. Other common values are 100, 255, 1023, 4095, and 65535. Even when 1, they are still taken to be non-linear Signal values.

Value

a data.frame with N rows and these columns

RGB

signal RGB. If TF is not 1, all input linear RGB values are clamped to the unit cube, which implies that the signal RGBs are inside the cube [0,maxSignal]^\(3\). Values are not rounded.

OutOfGamut

logical vector, TRUE means the input linear RGB was outside the unit cube before clamping it

In case of error, the functions return NULL.

References

Wikipedia. RGB color space. https://en.wikipedia.org/wiki/RGB_color_space

See Also

XYZfromRGB(), LinearRGBfromSignalRGB(), installRGB()

Examples

Run this code
# NOT RUN {
RGBfromXYZ( c(80.310897,90.306510,84.613450, 100,100,100)/100, max=255 )
##       RGB.R    RGB.G    RGB.B     OutOfGamut
##  1 230.1514 249.4148 225.2711          FALSE
##  2 255.0000 249.1150 244.4963           TRUE
# }

Run the code above in your browser using DataLab