adapt: Chromatic Adaptation Functions

adaptR Documentation

Chromatic Adaptation Functions

Description

Adapt XYZ, xyY, Lab, or Luv from a source viewing enviroment with a given illuminant, to a target viewing environment with a different illuminant.

Usage

## S3 method for class 'CAT'
adaptXYZ( x, XYZ.src )

## S3 method for class 'CAT'
adaptxyY( x, xyY.src )
## S3 method for class 'CAT'
adaptLab( x, Lab.src )
## S3 method for class 'CAT'
adaptLuv( x, Luv.src )

Arguments

x

a CAT object as returned from CAT()

XYZ.src

an Nx3 matrix, or a vector that can be converted to such a matrix, by rows. Each row has an XYZ in the source viewing environment.

xyY.src

an Nx3 matrix, or a vector that can be converted to such a matrix, by rows. Each row has an xyY in the source viewing environment.

Lab.src

an Nx3 matrix, or a vector that can be converted to such a matrix, by rows. Each row has an Lab in the source viewing environment.

Luv.src

an Nx3 matrix, or a vector that can be converted to such a matrix, by rows. Each row has an Luv in the source viewing environment.

Details

adaptXYZ() is the most fundamental of the group; it simply multiplies each of the input XYZs by x$M.

adaptxyY() converts xyY.src to XYZ, calls adaptXYZ(), and then converts back to xyY.tgt. And it does an additional check: if the xy of xyY.src is equal to the xy of x$source.xyY, then the xy of the returned xyY.tgt is set to be the xy of x$target.xyY.

adaptLab() and adaptLuv() work in a similar way. When Lab.src is transformed to XYZ, the whitepoint is set to x$source.XYZ. And when the adapted XYZ is transformed to adapted Lab, the whitepoint is set to target.XYZ.

Value

adaptXYZ() returns an Nx3 matrix with adapted XYZ. Each row has an XYZ in the target viewing environment.
adaptxyY() returns an Nx3 matrix with adapted xyY. Each row has an xyY in the target viewing environment.

adaptLab() and adaptLuv() return adapted Lab and Luv respectively.

References

Hunt, R. W. G. The Reproduction of Colour. 6th Edition. John Wiley & Sons. 2004.

International Color Consortium. ICC.1:2001-04. File Format for Color Profiles. 2001.

Lindbloom, Bruce. Chromatic Adaptation. http://brucelindbloom.com/Eqn_ChromAdapt.html

Wikipedia. CIECAM02. https://en.wikipedia.org/wiki/CIECAM02

See Also

CAT(), standardXYZ()

Examples

# try the Bradford method
bCAT = CAT( 'D50', 'D65', method='bradford' )

adaptXYZ( bCAT, c(1,1,0.5) )
##               X         Y         Z
##  [1,] 0.9641191 0.9921559 0.6567701


adaptLab( bCAT, c(50,20,-10) )
##              L        a         b
##  [1,] 49.97396 20.84287 -10.19661      # as expected, there is a change

adaptLab( bCAT, c(40,0,0) )
##        L a b
##  [1,] 40 0 0   # but adaptLab() always preserves neutrals


adaptLuv( bCAT, c(40,0,0) )
##        L u v
##  [1,] 40 0 0   # and adaptLuv() also preserves neutrals



# try the scaling method - now XYZ are scaled independently
sCAT = CAT( 'D50', 'D65', method='scaling' )

adaptLab( sCAT, c(50,20,-10) )
##        L  a   b
##  [1,] 50 20 -10    with sCAT, adaptLab() is now the identity for *all* colors


adaptLuv( sCAT, c(50,-20,10) )
##        L         u        v
##  [1,] 50 -18.32244 11.29946    but adaptLuv() is NOT the identity for all colors

spacesXYZ documentation built on May 29, 2024, 6:33 a.m.