Title: | Standard and User-Defined RGB Color Spaces, with Conversion Between RGB and CIE XYZ |
---|---|
Description: | Standard RGB spaces included are sRGB, 'Adobe' RGB, 'ProPhoto' RGB, BT.709, and others. User-defined RGB spaces are also possible. There is partial support for ACES Color workflows. |
Authors: | Glenn Davis [aut,cre] |
Maintainer: | Glenn Davis <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.5-0 |
Built: | 2024-11-03 07:14:29 UTC |
Source: | CRAN |
Each of these functions returns a TransferFunction
object,
that depends on the argument values passed to it.
The returned object has the parameter values "locked in".
These TransferFunction
objects are a mixture of EOTFs, OETFs, OOTFs, and general-purpose transfer functions.
power.OETF( gamma ) power.EOTF( gamma ) power.OOTF( gamma ) BT.1886.EOTF( gamma=2.4, Lb=0, Lw=1 ) XYZfromRGB.TF( primaries, white ) affine.TF( y0, y1 )
power.OETF( gamma ) power.EOTF( gamma ) power.OOTF( gamma ) BT.1886.EOTF( gamma=2.4, Lb=0, Lw=1 ) XYZfromRGB.TF( primaries, white ) affine.TF( y0, y1 )
gamma |
the value of |
Lb |
the black level |
Lw |
the white level |
primaries |
a 3x2 or 4x2 matrix; see Details |
white |
a vector of length 1, 2, or 3; see Details |
y0 |
the number to which 0 maps |
y1 |
the number to which 1 maps |
There are 3 valid combinations of primaries
and white
, as given in this table:
dim(primaries) |
length(white) |
Description |
4x2 | 1 | primaries is a 4x2 matrix with CIE xy chromaticities of R,G,B,W in the rows |
3x2 | 2 | primaries is a 3x2 matrix with CIE xy chromaticities of R,G,B in the rows |
3x2 | 3 | primaries is a 3x2 matrix with CIE xy chromaticities of R,G,B in the rows |
If length(white)
is 1, then white
is the whitepoint Y.
If length(white)
is 2, then white
is the whitepoint xy (CIE chromaticity);
the whitepoint Y is taken to be 1.
If length(white)
is 3, white
is the whitepoint XYZ (CIE tristimulus).
primaries
can also be a plain numeric vector of length 6 or 8,
which is then converted to a 3x2 or 4x2 matrix, by row.
power.OETF()
returns a TransferFunction
with the classical power law.
power.EOTF()
returns a TransferFunction
with the classical power law.
power.OOTF()
is the same as power.EOTF()
,
but having a different name may make the creation of new RGB spaces clearer.
All three of these map [0,1] to [0,1].
BT.1886.EOTF()
returns a TransferFunction
that maps [0,1] to
[Lb
,Lw
], with non-linearity given by gamma
.
The BT.1886 standard has details in Annex 1.
XYZfromRGB.TF()
returns a 3D TransferFunction
that is linear
and maps RGB=(1,1,1) to the XYZ of white.
The domain is set to the ACES cube and the range is set to the smallest enclosing box.
For the inverse one can use
XYZfromRGB.TF()^-1
.
affine.TF()
returns a 1D TransferFunction
that maps
0 → and 1 →
in an affine way.
One must have
, but is is OK to have
.
No quantities are associated with these values; the function is intended for arbitrary 1D scaling.
BT.1886. Reference electro-optical transfer function for flat panel displays used in HDTV studio production. March 2011.
sRGB.EOTF |
the standardized sRGB transfer function |
BT.709.EOTF |
the standardized BT.709 transfer function |
BT.2020.EOTF |
the standardized BT.2020 transfer function |
ProPhotoRGB.EOTF |
the standardized ProPhotoRGB transfer function |
SMPTE.240M.EOTF |
the standardized SMPTE-240M transfer function |
All of these are built-in TransferFunction
objects;
they have no parameters and are ready-to-go.
All are EOTFs and have domain and range the interval [0,1], and all are monotone increasing.
All are defined in 2 pieces, with a linear segment near 0.
All are easily inverted.
Wikipedia. sRGB. https://en.wikipedia.org/wiki/SRGB.
BT.709. Parameter values for the HDTV standards for production and international programme exchange. June 2015.
BT.2020. Parameter values for ultra-high definition television systems for production and international programme exchange. October 2015.
Wikipedia. ProPhoto RGB. https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space.
ANSI/SMPTE 240M-1995. SMPTE STANDARD for Television Signal Parameters 1125-Line High-Definition Production Systems.
# make plot comparing 5 EOTFs colvec = c('black','red','blue','green','orange') plot( sRGB.EOTF, color=colvec[1], main="The Basic 5 EOTFs" ) plot( BT.709.EOTF, color=colvec[2], add=TRUE ) plot( BT.2020.EOTF, color=colvec[3], add=TRUE ) plot( ProPhotoRGB.EOTF, color=colvec[4], add=TRUE ) plot( SMPTE.240M.EOTF, color=colvec[5], add=TRUE ) legend( 'topleft', legend=c('sRGB','BT.709','BT.2020','ProPhotoRGB','SMPTE.240M'), col=colvec, bty='n', lty=1, lwd=2 )
# make plot comparing 5 EOTFs colvec = c('black','red','blue','green','orange') plot( sRGB.EOTF, color=colvec[1], main="The Basic 5 EOTFs" ) plot( BT.709.EOTF, color=colvec[2], add=TRUE ) plot( BT.2020.EOTF, color=colvec[3], add=TRUE ) plot( ProPhotoRGB.EOTF, color=colvec[4], add=TRUE ) plot( SMPTE.240M.EOTF, color=colvec[5], add=TRUE ) legend( 'topleft', legend=c('sRGB','BT.709','BT.2020','ProPhotoRGB','SMPTE.240M'), col=colvec, bty='n', lty=1, lwd=2 )
The function composition(TF1,TF2)
returns a TransferFunction
that is
TF1
followed by TF2
.
Four equivalent infix operators are also available.
## S3 method for class 'TransferFunction' composition( TF1, TF2 ) ## S3 method for class 'TransferFunction' TF1 * TF2 ## S3 method for class 'TransferFunction' TF1 %;% TF2 ## S3 method for class 'TransferFunction' TF1 %X% TF2 ## S3 method for class 'TransferFunction' TF2 %O% TF1 identity.TF ## S3 method for class 'TransferFunction' is.identity( TF )
## S3 method for class 'TransferFunction' composition( TF1, TF2 ) ## S3 method for class 'TransferFunction' TF1 * TF2 ## S3 method for class 'TransferFunction' TF1 %;% TF2 ## S3 method for class 'TransferFunction' TF1 %X% TF2 ## S3 method for class 'TransferFunction' TF2 %O% TF1 identity.TF ## S3 method for class 'TransferFunction' is.identity( TF )
TF1 |
a |
TF2 |
a |
TF |
a |
In order to be composed, the dimensions of TF1
and TF2
must be equal,
or the dimension of one of them must be 1.
In the latter case, the function is applied to each coordinate in exactly the same way.
All the above represent the function TF1
followed by TF2
.
In mathematics this operation is usually called composition of functions
(and composition of morphisms in category theory),
and in computer science and BT.2100 and BT.2390 it is called the concatenation.
In BT.2390 it is also called the cascade.
The ACES literature uses infix notation with the symbol '+'
which is unfortunate because in mathematics
the plus symbol is only used for commutative operations, which composition certainly is not.
The symbol '*'
is offered here as an alternative,
since '*'
does not imply commutativity (e.g. as in MATLAB's matrix multiplication).
In computer science the symbol ';'
is common, and so %;%
is offered as an alternative.
In BT.2100 and BT.2390 the symbol ⊗ is used, and so %X%
is offered as an alternative.
And finally, in mathematics ○ is used but in the opposite order,
so that TF2 %O% TF1
is identical to composition(TF1,TF2)
.
Each TransferFunction
object is actually a list of so-called elementary transfer functions.
If TF1
has elementary functions and
TF2
has elementary functions,
then
composition(TF1,TF2)
has elementary functions.
It can be strictly less if there is cancellation of elementary functions at the end of
TF1
and the beginning of TF2
.
composition(TF1,TF2)
returns a TransferFunction
object,
which applies TF1
followed by TF2
.
The individual objects TF1
and TF2
are stored inside the returned object.
In case of ERROR it returns NULL
.
The 4 infix operators above all invoke composition()
.
identity.TF
is a built-in global TransferFunction
object which is a
universal identity for composition.
This means that for any TransferFunction
TF
,
TF*identity.TF = identity.TF*TF = TF
.
Moreover, TF*TF^-1 = TF^1*TF = identity.TF
.
This is *not* the same as base::identity()
.
is.identity(TF)
tests whether TF
is the universal identity,
and returns TRUE
or FALSE
.
Technical Bulletin. TB-2018-002. ACES Output Transform Details. June 2018 (draft).
ACES Retrospective and Enhancements March 2017.
BT.2100. Image parameter values for high dynamic range television for use in production and international programme exchange. June 2017.
BT.2390. High dynamic range television for production and international programme exchange. April 2018.
TransferFunction
,
transfer()
,
inverse()
comp = power.OOTF(2.2) * power.OOTF(1.4) x = 0:100 / 100 max( abs( transfer(comp,x) - transfer(power.OOTF(2.2*1.4),x) ) ) # 1.110223e-16 comp * comp^-1 ## This is a universal identity TransferFunction. is.identity(comp * comp^-1) # TRUE identical( comp * identity.TF, comp ) # TRUE
comp = power.OOTF(2.2) * power.OOTF(1.4) x = 0:100 / 100 max( abs( transfer(comp,x) - transfer(power.OOTF(2.2*1.4),x) ) ) # 1.110223e-16 comp * comp^-1 ## This is a universal identity TransferFunction. is.identity(comp * comp^-1) # TRUE identical( comp * identity.TF, comp ) # TRUE
DCDM.EOTF |
the standardized DCDM transfer function |
This is a TransferFunction
designed to be applied to XYZ, instead of the usual RGB.
The electrical encoding of XYZ is denoted X'Y'Z'.
The EOTF is:
and similarly for Y and Z.
SMPTE Standard RP 431-2. D-Cinema Quality - Reference Projector and Environment for the Display of DCDM in Review Rooms and Theaters. 2011.
FullRangeToSMPTE.TF |
the standardized SMPTE range transfer function |
This is a TransferFunction
object that maps from non-linear display signal RGB to itself.
It maps from the full range [0,1] to the
smaller range [ 64/1023, 940/1023 ] [ 0.06256109, 0.9188661 ].
The latter is the 10-bit "legal-SMPTE"" range.
It does this in an affine way, and in fact simply uses
affine.TF()
.
The Hybrid Log-Gamma OETF is a transfer function that allows for the display of high dynamic range (HDR) video.
The version here is that supported by the
ACES (Academy Color Encoding System) and
HEVC (High Efficiency Video Coding) standards.
For use with ACES, a specialized HLG-based OOTF is provided that references the Perceptual Quality (PQ) EOTF.
It converts the ST.2084 (PQ) output to HLG using the method specified in Section 7 of BT.2390-0.
HLG.OETF() HLG.OOTF( gamma=1.2, Lb=0, Lw=1000 )
HLG.OETF() HLG.OOTF( gamma=1.2, Lb=0, Lw=1000 )
gamma |
the applied exponent, from scene linear to display linear |
Lb |
the luminance of black, in |
Lw |
the luminance of white, in |
HLG.OOTF()
is 3D and does not operate on each channel independently.
It uses a scaling factor based on these RGB weights - (0.2627,0.6780,0.0593) - from Section 7 of BT.2390.
HLG.OETF()
returns a univariate TransferFunction
that maps
linear scene RGB to signal display RGB.
The interval [0,1] maps to [0,1] (as in the HVEC standard).
HLG.OOTF()
returns a multivariate TransferFunction
of dimension 3
that maps linear scene RGB to linear display RGB.
It maps the cube [0,1] to the cube [
Lb
,Lw
],
but the image is only a proper subset of the cube.
ST-2084. SMPTE Standard - High Dynamic Range Electro-Optical Transfer Function of Mastering Reference Displays. 2014.
BT.2390. High dynamic range television for production and international programme exchange. April 2018.
H.265 : High Efficiency Video Coding. https://www.itu.int/rec/T-REC-H.265-201802-I/en. 2018-02-13.
The function inverse()
returns a TransferFunction
that is the inverse
of the argument (if the argument is invertible).
is.invertible()
tests whether a TransferFunction object has an inverse.
## S3 method for class 'TransferFunction' inverse( TF ) ## S3 method for class 'TransferFunction' TF ^ n ## S3 method for class 'TransferFunction' is.invertible( TF )
## S3 method for class 'TransferFunction' inverse( TF ) ## S3 method for class 'TransferFunction' TF ^ n ## S3 method for class 'TransferFunction' is.invertible( TF )
TF |
a |
n |
an integer exponent; valid values are -1, 0, and 1 |
inverse()
returns a TransferFunction
object obtained by
swapping fun
and funinv
and
swapping domain
and range
.
The names of the elements composing TF
are changed appropriately.
If TF
is not invertible, it returns NULL
.
If n=-1
, TF^n
returns inverse(TF)
.
If n=1
, it returns TF
.
If n=0
, it returns the universal identity.TF
.
For any other value of n
it returns NULL
.
is.invertible()
returns TRUE
or FALSE
.
Convert signal RGB coordinates to XYZ, or to linear RGB
XYZfromRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 ) LinearRGBfromSignalRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )
XYZfromRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 ) LinearRGBfromSignalRGB( 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 → linear RGB using LinearRGBfromSignalRGB()
and all other the given arguments
linear RGB → XYZ using the appropriate 3x3 matrix for the given space
and which
XYZfromRGB()
returns a data.frame
with N rows and these columns:
XYZ |
the calculated XYZ vectors. These are for viewing under the white point of the given RGB space. |
OutOfGamut |
a logical vector. TRUE means the input signal RGB is outside the cube |
LinearRGBfromSignalRGB()
returns a data.frame
with N rows and these columns:
RGB |
the calculated linear RGB vectors, either scene linear or display linear. |
OutOfGamut |
a logical vector. TRUE means the input signal RGB is outside the cube |
In case of error, both functions return NULL.
Wikipedia. RGB color space. https://en.wikipedia.org/wiki/RGB_color_space
RGBfromXYZ()
,
SignalRGBfromLinearRGB()
,
installRGB()
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
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
Retrieve or set the metadata of a TransferFunction object. The user is free to set this as he/she wishes.
## S3 method for class 'TransferFunction' metadata( x, ...) ## S3 replacement method for class 'TransferFunction' metadata( x, add=FALSE ) <- value
## S3 method for class 'TransferFunction' metadata( x, ...) ## S3 replacement method for class 'TransferFunction' metadata( x, add=FALSE ) <- value
x |
a |
... |
optional names of metadata to return |
value |
a named |
add |
if |
The metadata list is stored as attr(x,'metadata')
.
After construction this list is empty.
metadata(x)
with no additional arguments returns the complete named list of metadata.
If arguments are present, then only those metadata
items are returned.
## Not run: # get list of *all* metadata metadata(TF) # get just the number 'gamma' metadata( TF, 'gamma' ) # alternative method to get just the number 'gamma' metadata( TF )$gamma # set the 'date' metadata( TF ) = list( date="2016-04-01" ) ## End(Not run)
## Not run: # get list of *all* metadata metadata(TF) # get just the number 'gamma' metadata( TF, 'gamma' ) # alternative method to get just the number 'gamma' metadata( TF )$gamma # set the 'date' metadata( TF ) = list( date="2016-04-01" ) ## End(Not run)
Miscellaneous TransferFunction
methods
## S3 method for class 'TransferFunction' dimension( TF ) ## S3 method for class 'TransferFunction' domain( TF ) ## S3 method for class 'TransferFunction' orientation( TF )
## S3 method for class 'TransferFunction' dimension( TF ) ## S3 method for class 'TransferFunction' domain( TF ) ## S3 method for class 'TransferFunction' orientation( TF )
TF |
a |
dimension()
returns a positive integer - the dimension of the domain and range of TF
.
If TF
is a universal identity, it returns NA
.
domain()
returns a 2xN matrix with the domain box of TF
,
where N is dimension(TF)
.
If TF
is a universal identity, it returns NA
.
orientation()
returns a real number.
If the value is positive it means that TF
preserves orientation.
If the value is negative it means that TF
reverses orientation.
When dimension(TF)
=1, this simply corresponds to
the function being monotone increasing or decreasing, respectively.
In case of ERROR, the function returns NA
.
TF = affine.TF( 1, 108 ) dimension(TF) # 1 orientation(TF) # 107 orientation( affine.TF( 100, 1 ) ) # -99 domain(TF) ## AU ## min 0 ## max 1
TF = affine.TF( 1, 108 ) dimension(TF) # 1 orientation(TF) # 107 orientation( affine.TF( 100, 1 ) ) # -99 domain(TF) ## AU ## min 0 ## max 1
This parameterized OOTF maps from ACES (linear scene) RGB to linear display RGB
(both of these are optical in nature).
This transform bypasses non-linear signal display RGB (which is electrical in nature).
general.OOTF( display_pri, Ymin=0.00010, Ymid=7.2, Ymax=108, observerWP=NULL, limiting_pri=NULL, surround='dark', dynrange='SDR', glowmod='1.1', redmod='1.1' )
general.OOTF( display_pri, Ymin=0.00010, Ymid=7.2, Ymax=108, observerWP=NULL, limiting_pri=NULL, surround='dark', dynrange='SDR', glowmod='1.1', redmod='1.1' )
display_pri |
a 4x2 matrix containing the display primaries, or a numeric vector of length 8
that can be converted to such a matrix, by row.
Some built-in matrices are |
Ymin |
the minimum display luminance, in |
Ymid |
the middle display luminance, in |
Ymax |
the maximum display luminance, in |
observerWP |
the xy chromaticity of the assumed observer whitepoint.
This is used to make a Chromatic Adaptation Transform (CAT) from the ACES whitepoint (approximately D60)
to the assumed observer whitepoint.
If |
limiting_pri |
a 4x2 matrix containing the limiting primaries, or a numeric vector of length 8
that can be converted to such a matrix, by row.
If |
surround |
The level of the surround luminance.
Valid values are |
dynrange |
the dynamic range of the display system.
Valid values are |
glowmod |
the version of the Glow Modifier to use.
The only version currently supported is |
redmod |
the version of the Red Modifier to use.
The only version currently supported is |
The transfer is complicated; here is a summary of the steps:
glow module (see argument glowmod
)
red modifier (see argument redmod
)
matrix conversion from AP0 RGB → AP1 RGB
clamp to non-negative RGB
global desaturation (as in RRT.TF
)
single-stage tone-scale (SSTS) using Ymin
, Ymid
, and Ymax
absolute luminance to linear code-value, in cube [0,1]
matrix conversion from AP1 RGB to XYZ
dim surround compensation (optional, see arguments surround
and dynrange
)
clamp XYZ to limiting primaries (optional, see argument limiting_pri
)
adapt XYZ from ACES whitepoint to observer whitepoint (optional, see argument observerWP
)
matrix conversion from XYZ to linear display RGB (see argument display_pri
)
scale and roll-white to avoid clipping (optional, only when observerWP
is ACES whitepoint and display whitepoint is D65 or DCI whitepoint)
clamp to non-negative RGB
general.OOTF()
returns a TransferFunction
of dimension 3
that maps ACES RGB to linear display RGB.
The domain of the returned TransferFunction
depends on the values of
Ymin
, Ymid
, and Ymax
.
The range is [0,1], for which clamping may be used.
The metadata
contains the display primaries and whitepoint,
which is useful in installRGB()
.
This function was based on source code at:
https://github.com/ampas/aces-dev;
especially the file ACESlib.OutputTransforms.ctl
.
This transform is a sub-transform of the function outputTransform()
;
it omits the final EOTF and optional Full-to-SMPTE range.
ST 2065-1:2012. SMPTE Standard - Academy Color Encoding Specification (ACES). 2013.
TransferFunction
,
installRGB()
,
metadata()
,
Standard Primaries
A partial Output Device Transform (PODT) maps from OCES to linear display RGB
(both of these are optical in nature).
The adjective "partial" is used because this
is an ODT that omits the final OETF (which maps from linear display RGB to signal display RGB).
This PODT is parameterized.
general.PODT( display_pri, Ymax=1, observerWP=NULL, surround='dark', limiting_pri=NULL )
general.PODT( display_pri, Ymax=1, observerWP=NULL, surround='dark', limiting_pri=NULL )
display_pri |
a 4x2 matrix containing the display primaries, or a numeric vector of length 8
that can be converted to such a matrix, by row.
Some built-in matrices are |
Ymax |
the maximum luminance of the output device, in |
observerWP |
the xy chromaticity of the assumed observer whitepoint.
This is used to make a Chromatic Adaptation Transform (CAT) from the ACES whitepoint (approximately D60)
to the assumed observer whitepoint.
If |
surround |
The level of the surround luminance.
Valid values are |
limiting_pri |
a 4x2 matrix containing the limiting primaries, or a numeric vector of length 8
that can be converted to such a matrix, by row.
If |
The transfer is complicated; here is a summary of the steps:
matrix conversion from AP0 RGB → AP1 RGB
clamp to non-negative RGB
segmented spline, assuming CINEMA_WHITE
=48 nit
absolute luminance to linear code-value, in cube [0,1]
scale and roll-white to avoid clipping (optional, only when observerWP
is ACES whitepoint and display whitepoint is D65 or DCI whitepoint)
dim surround compensation with conversion to XYZ and back again (optional, see argument surround
)
matrix conversion from AP1 RGB to XYZ
adapt XYZ from ACES whitepoint to observer whitepoint (optional, see argument observerWP
)
clamp XYZ to limiting primaries (optional, see argument limiting_pri
)
matrix conversion from XYZ to linear display RGB (but not for DCDM, see argument display_pri
)
clamp linear display RGB (or XYZ for DCDM) to the cube [0,1]
general.PODT()
returns a TransferFunction
of dimension 3
that maps OCES RGB to linear display RGB.
The domain is [0,10000] and the range is [0,1]
.
The metadata
contains the display primaries and whitepoint,
which is useful in installRGB()
.
This function was based on source code at:
https://github.com/ampas/aces-dev;
especially the files under the folder aces-dev-master/transforms/ctl/odt/
.
ST 2065-1:2012. SMPTE Standard - Academy Color Encoding Specification (ACES). 2013.
TransferFunction
,
installRGB()
,
metadata()
,
RRT.TF
,
Standard Primaries
The Perceptual Quantizer is a transfer function that allows for the display of high dynamic range (HDR) video.
PQ.EOTF( Lmax=10000 )
PQ.EOTF( Lmax=10000 )
Lmax |
the maximum luminance, in |
PQ.EOTF()
returns a TransferFunction
that maps signal-display RGB to linear-display RGB.
The interval [0,1] maps to [0,Lmax
].
ST-2084. SMPTE Standard - High Dynamic Range Electro-Optical Transfer Function of Mastering Reference Displays. 2014.
plot a TransferFunction
of dimension 1, 2, or 3.
## S3 method for class 'TransferFunction' plot( x, color='red', main=TRUE, add=FALSE, ... )
## S3 method for class 'TransferFunction' plot( x, color='red', main=TRUE, add=FALSE, ... )
x |
a |
color |
Any value acceptable as the |
main |
If |
add |
If |
... |
other graphical parameters, see Details |
If N=1 a conventional plot is drawn using graphics::lines()
.
Commonly used graphical parameters applicable when N=1 are:
log |
passed on to plot.default() .
Care must be taken because many transfer functions have 0 in their domains. |
If N=2 a grid is generated in the domain box, and the image of that grid is plotted using using graphics::lines()
.
If N=3 a grid is generated in the domain box, and the image of that grid is plotted in 3D
using rgl::lines3d()
.
TRUE
or FALSE
graphics::lines()
,
rgl::lines3d()
RGB patches are a very common way of comparing color renderings. This function draws rectangular patches, and can also draw triangles formed by omitting one vertex from the rectangle.
plotPatchesRGB( obj, space='sRGB', which='signal', maxColorValue=1, background='gray50', shape='full', add=FALSE, labels=FALSE, ... )
plotPatchesRGB( obj, space='sRGB', which='signal', maxColorValue=1, background='gray50', shape='full', add=FALSE, labels=FALSE, ... )
obj |
an Nx3 matrix of RGBs for N patches, preferably with assigned |
space |
the name of an installed RGB space. When the input RGB is linear, a transfer function of this RGB space is used to convert linear RGB to signal RGB, see Details. |
which |
the meaning of the RGB values in |
maxColorValue |
a positive number used for input RGB scaling, see Details |
background |
the color for the background behind all the patches.
If it is a character string, it is passed directly to |
shape |
If |
add |
if |
labels |
controls how the patches are labeled, using |
... |
additional arguments passed to |
If which='signal'
then the input RGBs are converted to hex codes using
rgb()
using the maxColorValue
argument,
and the space
argument is ignored.
If which='scene'
or which='display'
then the input linear RGBs are normalized
by division by maxColorValue
, and then converted to signal RGB using
SignalRGBfromLinearRGB()
with the space
argument.
The signal RGB is then converted to hex codes using rgb()
.
If obj
is a matrix, or a data.frame without columns LEFT,TOP,WIDTH,HEIGHT
,
then the patches are drawn vertically stacked and abutting from top to bottom.
TRUE
if successful, and FALSE
otherwise
SignalRGBfromLinearRGB()
,
installRGB()
,
rgb()
set.seed(0) RGB = round( 255 * matrix( runif(6*3), 6, 3 ) ) plotPatchesRGB( RGB, max=255 )
set.seed(0) RGB = round( 255 * matrix( runif(6*3), 6, 3 ) ) plotPatchesRGB( RGB, max=255 )
Each TransferFunction
object is actually a list of so-called elementary transfer functions;
for details on this see composition()
.
This print()
calls an internal print()
function for each elementary function individually.
The internal print()
also calls an
internal validate()
(with default arguments) which runs some basic tests
and formats the results nicely for printing, see validate()
.
## S3 method for class 'TransferFunction' print( x, ... )
## S3 method for class 'TransferFunction' print( x, ... )
x |
a |
... |
further arguments ignored, but required by the generic |
The function returns TRUE
or FALSE
.
TransferFunction
,
validate()
,
composition()
tf = sRGB.EOTF^-1 * power.EOTF(2.5) tf ## #-------------------- [sRGB.EOTF]^-1 ---------------------# ## [sRGB.EOTF]^-1 is a univariate TransferFunction. ## domain: [0,1] (linear display) ## range: [0,1] (non-linear signal) ## invertible: Yes ## orientation: preserving ## range-test points = 1300, max(distance)=0. ## validation: Passed ## #-------------------- power.EOTF(2.5) ---------------------# ## power.EOTF(2.5) is a univariate TransferFunction. ## domain: [0,1] (non-linear signal) ## range: [0,1] (linear display) ## invertible: Yes ## orientation: preserving ## range-test points = 1300, max(distance)=0. ## validation: Passed
tf = sRGB.EOTF^-1 * power.EOTF(2.5) tf ## #-------------------- [sRGB.EOTF]^-1 ---------------------# ## [sRGB.EOTF]^-1 is a univariate TransferFunction. ## domain: [0,1] (linear display) ## range: [0,1] (non-linear signal) ## invertible: Yes ## orientation: preserving ## range-test points = 1300, max(distance)=0. ## validation: Passed ## #-------------------- power.EOTF(2.5) ---------------------# ## power.EOTF(2.5) is a univariate TransferFunction. ## domain: [0,1] (non-linear signal) ## range: [0,1] (linear display) ## invertible: Yes ## orientation: preserving ## range-test points = 1300, max(distance)=0. ## validation: Passed
The fixed RRT.TF
corresponds to the RRT in aces-dev 1.1.
A parameterized version general.RRT()
is also provided - for experimentation.
This one returns a TransferFunction
with the argument values "locked-in".
RRT.TF general.RRT( glowmod="1.1", redmod="1.1" )
RRT.TF general.RRT( glowmod="1.1", redmod="1.1" )
glowmod |
the version of the Glow Modifier to use.
The only version currently supported is |
redmod |
the version of the Red Modifier to use.
The only version currently supported is |
RRT.TF
is a Transferfunction
that maps ACES RGB to OCES RGB.
Both spaces are relative to the AP1 primaries.
RRT.TF
is constructed by calling general.RRT()
with its default arguments.
The transfer is complicated; here is a summary of the steps
starting with ACES RGB as input:
glow module (see argument glowmod
)
red modifier (see argument redmod
)
matrix conversion from AP0 RGB → AP1 RGB
clamp to non-negative RGB
global desaturation
segmented spline, applied to each channel separately
matrix conversion from AP1 → AP0 (now OCES RGB)
general.RRT()
returns a Transferfunction
that maps ACES RGB to OCES RGB.
The domain is [0,47000] and the range is [0,10000]
.
ST 2065-1:2012. SMPTE Standard - Academy Color Encoding Specification (ACES). 2013.
Install/uninstall RGB spaces in a dictionary.
The dictionary comes with 8 RGB spaces pre-installed.
To query the dictionary, use getRGB()
and summaryRGB()
.
installRGB( space, scene, display=NULL, OETF=NULL, EOTF=NULL, OOTF=NULL, overwrite=FALSE ) uninstallRGB( space )
installRGB( space, scene, display=NULL, OETF=NULL, EOTF=NULL, OOTF=NULL, overwrite=FALSE ) uninstallRGB( space )
space |
name of the RGB space to install or uninstall or query.
After the RGB space is installed,
the string |
scene |
the specification of the scene primaries and whitepoint.
There are many options here.
The 1st option is a 4x2 matrix with the CIE xy chromaticities of R,G,B,W in the rows, in that order.
The 2nd option is a list with 2 items: the primaries data and the whitepoint data.
These are described in the section Primaries and Whitepoint Details below.
If |
display |
the specification of the display primaries and whitepoint.
The options are the same as for argument |
OETF |
a |
EOTF |
a |
OOTF |
a |
overwrite |
in |
Both installRGB()
and uninstallRGB()
check for matches with existing names.
The matching is full (not partial) and case-insensitive.
So it is impossible to have 2 spaces that differ only in case.
installRGB()
and uninstallRGB()
return TRUE
or FALSE
.
The arguments scene
and display
can be a list with 2 items:
primaries
and white
in that order.
There are 3 options for this list, as given in this table:
dim(primaries) |
length(white) |
Description |
4x2 | 1 | primaries is a 4x2 matrix with CIE xy chromaticities of R,G,B,W in the rows |
3x2 | 2 | primaries is a 3x2 matrix with CIE xy chromaticities of R,G,B in the rows |
3x2 | 3 | primaries is a 3x2 matrix with CIE xy chromaticities of R,G,B in the rows |
If length(white)
is 1, then white
is the whitepoint Y.
If length(white)
is 2, then white
is the whitepoint xy (CIE chromaticity);
the whitepoint Y is taken to be 1.
If length(white)
is 3, white
is the whitepoint XYZ (CIE tristimulus).
The whitepoint is linearly transformed to RGB=(1,1,1).
For better numeric compatibility with standards, xy is recommended.
For better numeric compatibility with Lindbloom, XYZ is recommended.
See the Examples below.
The 3 transfer functions - OETF
, EOTF
, OOTF
- can be NULL
(the default) or given.
This yields 8 combinations, but only 6 are valid, as given in this table:
OETF |
EOTF |
OOTF |
Description |
given | given | given | INVALID |
given | given | OETF*EOTF |
OOTF is the composition OETF followed by EOTF |
given | OETF^-1*OOTF |
given | EOTF is the composition OETF^-1 followed by OOTF |
OOTF*EOTF^-1 |
given | given | OETF is the composition OOTF followed by EOTF^-1 |
given | OETF^-1 |
identity.TF |
EOTF is set to OETF^-1 , and OOTF is set to the identity |
EOTF^-1 |
given | identity.TF |
OETF is set to EOTF^-1 , and OOTF is set to the identity |
NULL |
NULL |
given | INVALID |
NULL |
NULL |
NULL |
all 3 transfer functions are set to identity.TF . |
Think of these 3 functions as forming a triangle. If all 3 are given, the transfers may be ambiguous, i.e. the triangle may not commute. If 2 functions are given, the 3rd is computed from those 2. If only 1 function is given, and it is EOTF or OETF, then it makes sense to make the other one the inverse of the given one, so that the OOTF is the identity. If only the OOTF is given, there is no well-defined way to define the other 2. If none are given, as in the last row, this might be useful for testing conversion between RGB and XYZ.
All the RGB spaces are stored in a dictionary.
If installRGB()
is successful, the installed space is only in
the dictionary until the end of the R session.
To make it persist, please put the function call in an R script that is executed
after the package is loaded.
The dictionary comes with 8 RGB spaces pre-installed.
Lindbloom, Bruce. RGB/XYZ Matrices. http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
getRGB()
,
summaryRGB()
RGBfromXYZ()
,
XYZfromRGB()
,
TransferFunction
,
power.OETF()
,
power.EOTF()
,
power.OOTF()
# install native RGB space for NEC PA242W display prim = matrix( c(0.675,0.316, 0.199,0.715, 0.157,0.026), 3, 2, byrow=TRUE ) installRGB( 'PA242W', scene=NULL, display=list(primaries=prim,white=c(0.95047,1,1.08883)), OETF=2 ) # install a linear version of sRGB (OETF=1) prim = matrix( c(0.64,0.33, 0.30,0.60, 0.15,0.06), 3, 2, byrow=TRUE ) installRGB( 'linear-sRGB', scene=NULL, display=list(prim,c(0.3127,0.3290)), OETF=1 ) # make plot comparing three EOTFs plot( getRGB('sRGB')$EOTF, col='black' ) plot( getRGB('linear')$EOTF, col='red', add=TRUE ) plot( getRGB('PA242W')$EOTF, col='blue', add=TRUE ) # Install an RGB space named 'HD+2.4', with encoding from BT.709 and display from BT.1886. # the OOTF for this space is non-trivial prim = matrix( c(0.64,0.33, 0.30,0.60, 0.15,0.06 ), 3, 2, byrow=TRUE ) white = c( 0.3127, 0.3290 ) installRGB( "HD+2.4", scene=NULL, display=list(prim,white), OETF=(BT.709.EOTF)^-1, EOTF=BT.1886.EOTF(), over=TRUE ) # make plot comparing two OOTFs plot( getRGB('HD+2.4')$OOTF, col='red') plot( getRGB('sRGB')$OOTF, col='black', add=TRUE )
# install native RGB space for NEC PA242W display prim = matrix( c(0.675,0.316, 0.199,0.715, 0.157,0.026), 3, 2, byrow=TRUE ) installRGB( 'PA242W', scene=NULL, display=list(primaries=prim,white=c(0.95047,1,1.08883)), OETF=2 ) # install a linear version of sRGB (OETF=1) prim = matrix( c(0.64,0.33, 0.30,0.60, 0.15,0.06), 3, 2, byrow=TRUE ) installRGB( 'linear-sRGB', scene=NULL, display=list(prim,c(0.3127,0.3290)), OETF=1 ) # make plot comparing three EOTFs plot( getRGB('sRGB')$EOTF, col='black' ) plot( getRGB('linear')$EOTF, col='red', add=TRUE ) plot( getRGB('PA242W')$EOTF, col='blue', add=TRUE ) # Install an RGB space named 'HD+2.4', with encoding from BT.709 and display from BT.1886. # the OOTF for this space is non-trivial prim = matrix( c(0.64,0.33, 0.30,0.60, 0.15,0.06 ), 3, 2, byrow=TRUE ) white = c( 0.3127, 0.3290 ) installRGB( "HD+2.4", scene=NULL, display=list(prim,white), OETF=(BT.709.EOTF)^-1, EOTF=BT.1886.EOTF(), over=TRUE ) # make plot comparing two OOTFs plot( getRGB('HD+2.4')$OOTF, col='red') plot( getRGB('sRGB')$OOTF, col='black', add=TRUE )
Query and summarize the installed RGB spaces. The RGB spaces are stored in a dictionary, which comes with 8 RGB spaces pre-installed. These spaces are: sRGB, AdobeRGB, ProPhotoRGB, AppleRGB, BT.709, BT.2020, 240M, and HD+2.4.
summaryRGB( verbosity=1 ) getRGB( space ) getWhiteXYZ( space, which='scene' )
summaryRGB( verbosity=1 ) getRGB( space ) getWhiteXYZ( space, which='scene' )
space |
name of the RGB space to query. The name matching is partial and case-insensitive. |
verbosity |
an integer that controls the return value of |
which |
the source of the whitepoint, either |
The function getWhiteXYZ()
is provided because some applications only need the whitepoint
for chromatic adaptation purposes, and this function is faster than getRGB()
.
summaryRGB()
, with the default verbosity=1
, returns a data.frame
with a row for each RGB space.
The row contains primary, whitepoint, and transfer function information for each space.
The primary/whitepoint data is for both scene and display; all the data is numerical and the columns are labeled.
There are 22 columns so the display is very wide.
The transfer function data is a very short string.
If the OETF is classical (pure 1/ power law), the string is 1/
.
If the OETF is not classical, the string is 1/~
,
where
is the best-fit (or approximate or effective)
to the OETF in the
-norm.
Similarly, if the EOTF is classical (pure power law) the string is
,
and if the EOTF is not classical the string is ~
.
The OOTF is the quotient (to 2 decimal places) of the gammas of EOTF and OETF
(either true gamma or best-fit gamma).
If either gamma is best-fit then the string is preceede by a '~'
,
which means effective.
If the TransferFunction
has dimension 1, but the domain and range are not the interval [0,1],
the string is '1D'
.
If the TransferFunction
has dimension 3, the string is '3D'
.
If verbosity=0
, summaryRGB()
returns the names of all the RGB spaces.
getRGB()
returns a list with these items:
space |
the full and original name of the RGB space |
scene |
a list with items primaries , whiteXYZ , RGB2XYZ , and XYZ2RGB |
display |
a list with items primaries , whiteXYZ , RGB2XYZ , and XYZ2RGB |
EOTF |
Electro-Optical Transfer Function |
OETF |
Opto-Electronic Transfer Function |
OOTF |
Opto-Optical Transfer Function, and numerically equal to OETF*EOTF |
The items in the lists scene
and display
are
primaries |
4x2 matrix with the xy chromaticities of the RGB primaries and white |
whiteXYZ |
XYZ of the display white point, which maps to RGB=(1,1,1) |
RGB2XYZ |
3x3 matrix taking RGB to XYZ |
XYZ2RGB |
3x3 matrix taking XYZ to RGB |
All transfer functions are actual TransferFunctions
objects,
and not the numerical exponent or character string name.
They are suitable for plotting with plot.TransferFunction()
; see the Examples.
In case of error, getRGB()
returns NULL.
getWhiteXYZ()
returns a numeric 3-vector with the XYZ of the whitepoint of the scene or the display.
In case of error it returns NULL
.
Lindbloom, Bruce. RGB/XYZ Matrices. http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
installRGB()
,
plot.TransferFunction()
# make plot comparing three EOTFs plot( getRGB('sRGB')$EOTF, col='black' ) plot( getRGB('BT.709')$EOTF, col='blue', add=TRUE ) plot( getRGB('ProPhotoRGB')$EOTF, col='red', add=TRUE )
# make plot comparing three EOTFs plot( getRGB('sRGB')$EOTF, col='black' ) plot( getRGB('BT.709')$EOTF, col='blue', add=TRUE ) plot( getRGB('ProPhotoRGB')$EOTF, col='red', add=TRUE )
Convert XYZ or Linear RGB to Signal RGB, multiple RGB spaces are available
RGBfromXYZ( XYZ, space='sRGB', which='scene', TF=NULL, maxSignal=1 ) SignalRGBfromLinearRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )
RGBfromXYZ( XYZ, space='sRGB', which='scene', TF=NULL, maxSignal=1 ) SignalRGBfromLinearRGB( RGB, space='sRGB', which='scene', TF=NULL, maxSignal=1 )
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 |
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 may be outside the corresponding domain box (either scene or display), see Details. |
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 non-linear |
In RGBfromXYZ()
, the conversion is done in 2 steps:
XYZ → linear RGB using the appropriate 3x3 matrix for the given space
and which
linear RGB → signal RGB using SignalRGBfromLinearRGB()
and all other the given arguments
a data.frame
with N rows and these columns
RGB |
signal RGB.
If |
OutOfGamut |
logical vector, TRUE means the input linear RGB was outside the domain box before clamping it. |
In case of error, the functions return NULL.
Wikipedia. RGB color space. https://en.wikipedia.org/wiki/RGB_color_space
XYZfromRGB()
,
LinearRGBfromSignalRGB()
,
installRGB()
,
identity.TF
RGBfromXYZ( c(80.310897,90.306510,84.613450, 100,100,100)/100, max=255 ) ## RGB.R RGB.G RGB.B OutOfGamut ## 1 230.1676 249.4122 225.2472 FALSE ## 2 255.0000 249.1125 244.4704 TRUE
RGBfromXYZ( c(80.310897,90.306510,84.613450, 100,100,100)/100, max=255 ) ## RGB.R RGB.G RGB.B OutOfGamut ## 1 230.1676 249.4122 225.2472 FALSE ## 2 255.0000 249.1125 244.4704 TRUE
xy Chromaticities for some standard primary sets. These include Red, Green, Blue, and White.
AP0_PRI |
ACES Scene-Referred Primaries, from SMPTE ST2065-1 |
AP1_PRI |
working space and rendering primaries for ACES 1.0 |
REC709_PRI |
Rec.709 (aka BT.709) primaries |
REC2020_PRI |
Rec.2020 (aka BT.2020) primaries |
P3D65_PRI |
RGB primaries from DCI-P3, with D65 for the whitepoint |
P3D60_PRI |
RGB primaries from DCI-P3, with ACES whitepoint (approximately D60) |
P3DCI_PRI |
RGB primaries from DCI-P3, with DCI whitepoint |
All of these are built-in 4x2 matrices, with xy coordinates in the rows, and in RGBW order.
ST 2065-1:2012. SMPTE Standard - Academy Color Encoding Specification (ACES). 2013.
SMPTE Standard RP 431-2. D-Cinema Quality - Reference Projector and Environment for the Display of DCDM in Review Rooms and Theaters. 2011.
Wikipedia. DCI-P3. https://en.wikipedia.org/wiki/DCI-P3.
BT.709. Parameter values for the HDTV standards for production and international programme exchange. June 2015.
BT.2020. Parameter values for ultra-high definition television systems for production and international programme exchange. October 2015.
AP0_PRI ## x y ## R 0.73470 0.26530 ## G 0.00000 1.00000 ## B 0.00010 -0.07700 ## W 0.32168 0.33767
AP0_PRI ## x y ## R 0.73470 0.26530 ## G 0.00000 1.00000 ## B 0.00010 -0.07700 ## W 0.32168 0.33767
The function transfer()
applies the given TransferFunction
to the
given vector or array x
and returns a numeric object of the same dimensions.
## S3 method for class 'TransferFunction' transfer( TF, x, domaincheck=TRUE )
## S3 method for class 'TransferFunction' transfer( TF, x, domaincheck=TRUE )
TF |
a |
x |
a numeric vector or array.
If N |
domaincheck |
check whether numbers or rows of |
Let N := dimension(TF)
.
If N=1 then x
can have any length or dimension;
the function is applied to each number in x
in a vectorized way,
and the returned object is then assigned the same dimensions as x
.
If x
is a matrix then the returned object is assigned the same rownames
.
If a number is NA
then the returned number is also NA
.
If N2 and
x
is an MxN matrix,
then the function is applied to each row of x
individually and the returned object
is a matrix with the same dimensions and rownames
as x
.
If any number in a row is NA
then the returned row is all NA
s.
If TF
is a universal identity (e.g. identity.TF
), the function returns x
with no checking.
In case of a global error (e.g. dimension mismatch) the function returns NULL
.
The function TransferFunction()
is the constructor for TransferFunction objects.
is.TransferFunction()
tests whether an object is a valid TransferFunction object.as.TransferFunction()
converts other variables to a TransferFunction object,
and is designed to be overridden by other packages.
TransferFunction( fun, funinv, domain, range, id=NULL ) is.TransferFunction(x) ## Default S3 method: as.TransferFunction( ... )
TransferFunction( fun, funinv, domain, range, id=NULL ) is.TransferFunction(x) ## Default S3 method: as.TransferFunction( ... )
fun |
a function that accepts a numeric argument, and returns one of the same length.
The dimension of |
funinv |
a function that the inverse for |
domain |
a 2xN matrix, or a numeric vector that can be converted to such a matrix, by column.
In each column, the entry in row 1 must be strictly less than the entry in row 2.
The columns of |
range |
a 2xN matrix, or a numeric vector that can be converted to such a matrix, by column.
The N here must be equal to the N for |
id |
a character string that is helpful when printing the object, and in logging messages.
If |
x |
an R object to test for being a valid TransferFunction object. |
... |
arguments for use in other packages. |
If fun
is univariate, then it must be able to accept a numeric vector of any length,
and apply the function to each number in the vector; i.e. fun
must be vectorized.
If a number in the vector is NA, then the function must silently return NA for that number;
usually this is not a problem.
The function is *not* required to test whether the number is in the domain
interval;
this is handled by the TransferFunction
code.
If fun
is multivariate with dimension N, then it must be able to accept a vector
of length N and return a vector of length N.
It is *not* required to accept an MxN matrix.
It is *not* required to test whether the vector is in the domain box.
The function funinv
has the same requirements as fun
.
TransferFunction()
returns a TransferFunction object, or NULL
in case of ERROR.
is.TransferFunction()
returns TRUE
or FALSE
.
It only checks the class
, using base::inherits()
.
as.TransferFunction.default()
issues an ERROR message and returns NULL
..
dimension()
,
composition()
,
is.invertible()
,
metadata()
,
inverse()
,
transfer()
,
orientation()
,
validate()
,
print.TransferFunction()
,
plot.TransferFunction()
# make a test TransferFunction myfun = function(x) {x*x} test = TransferFunction( myfun, sqrt, domain=c(0,3), range=c(0,9), id='test.TF' ) # print it test #-------------------- test.TF ---------------------# ## test.TF is a univariate TransferFunction. ## domain: [0,3] (x) ## range: [0,9] (y) ## invertible: Yes ## orientation: preserving ## range-test points = 1300, max(distance)=0. ## validation: Passed # and now plot it plot( test )
# make a test TransferFunction myfun = function(x) {x*x} test = TransferFunction( myfun, sqrt, domain=c(0,3), range=c(0,9), id='test.TF' ) # print it test #-------------------- test.TF ---------------------# ## test.TF is a univariate TransferFunction. ## domain: [0,3] (x) ## range: [0,9] (y) ## invertible: Yes ## orientation: preserving ## range-test points = 1300, max(distance)=0. ## validation: Passed # and now plot it plot( test )
Each TransferFunction
object is actually a list of so-called elementary transfer functions;
for details on this see composition()
.
This validate()
applies an internal validate()
function to each elementary function
individually.
The internal validate()
function generates some points in the domain of the function
and checks that all points are transfered into the range of the function.
If the function is also invertible, it checks that the inverse transfers back to the original point.
## S3 method for class 'TransferFunction' validate( TF, points=1300, tol=5.e-7, domain=NULL )
## S3 method for class 'TransferFunction' validate( TF, points=1300, tol=5.e-7, domain=NULL )
TF |
a |
points |
the number of points to test, in each elementary function |
tol |
the numerical tolerance for the inversion test - this is relative to the length of the corresponding side of the domain box |
domain |
a 2xN matrix to use as an alternate domain, for the first elementary function in the list only.
|
The function returns a logical vector of length M.
The value of the i'th element is the validation status of the i'th elementary function.
The returned vector has the attribute 'message'
which is a list of length M
with explanatory text.
For nicely formatted text see print()
.
TransferFunction
,
identity.TF
,
composition()
,
print.TransferFunction()