Linear RGB, XYZ, and Lab Calculation | R Documentation |
Convert signal RGB coordinates to linear RGB, XYZ, or Lab
LinearRGBfromSignalRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )
XYZfromRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )
LabfromRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )
RGB |
a numeric Nx3 matrix with non-linear signal RGB coordinates in the rows, or a vector that can be converted to such a matrix, by row.
These should be in the appropriate cube |
space |
the name of an installed RGB space. The name matching is partial and case-insensitive. |
which |
either |
TF |
if not |
maxSignal |
maximum value of the input signal |
In XYZfromRGB()
, the conversion is done in 2 steps:
signal RGB \rarrow linear RGB using LinearRGBfromSignalRGB()
and all other the given arguments
linear RGB \rarrow XYZ using the 3x3 matrix for the given space
and which
XYZfromRGB()
returns a data.frame
with N rows and these columns:
OutOfGamut |
a logical vector. TRUE means the input signal RGB is outside the cube |
XYZ |
the calculated XYZ vectors, using the appropriate 3x3 matrix for the RGB space.
These are for viewing under the white point (either |
LabfromRGB()
returns a data.frame
with N rows and these columns:
OutOfGamut |
a logical vector. TRUE means the input signal RGB is outside the cube |
Lab |
the calculated Lab vectors.
First XYZ is calculated using |
LinearRGBfromSignalRGB()
returns a data.frame
with N rows and these columns:
OutOfGamut |
a logical vector. TRUE means the input signal RGB is outside the cube |
RGB |
the calculated linear RGB vectors, either scene linear or display linear, as specified by |
In case of error, all functions return NULL.
Wikipedia. RGB color space. https://en.wikipedia.org/wiki/RGB_color_space
RGBfromXYZ()
,
SignalRGBfromLinearRGB()
,
installRGB()
,
spacesXYZ::LabfromXYZ()
XYZfromRGB( c(128,200,255, 0,0,0, 255,255,255), max=255 )$XYZ * 100
## X Y Z
## [1,] 47.60334 53.11601 102.3549
## [2,] 0.00000 0.00000 0.0000
## [3,] 95.04559 100.00000 108.9058
XYZfromRGB( c(128,200,255, 0,0,0, 255,255,255), space='Adobe', max=255 )$XYZ * 100
## X Y Z
## [1,] 42.36398 50.82876 103.8704
## [2,] 0.00000 0.00000 0.0000
## [3,] 95.04559 100.00000 108.9058
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.