cie

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

README

cie

CIE is the International Commission on Illumination which establishes standards for representing color information.

This package contains standard values and routines for converting between standard RGB color space (sRGB), and the the CIE standard color spaces of XYZ and Lab* (LAB).

XYZ color space (1931): standard color basis space

https://en.wikipedia.org/wiki/CIE_1931_color_space

  • Y is the luminance (overall brightness) = 0.2 red + 0.7 green + 0.07 blue
  • Z is purely the short wavelength (blue) = 0.02 red + 0.1 green + 0.95 blue
  • X is a mix of the three CIE LMS cone responses chosen to be nonnegative: 1.9 long (red), -1.1 medium (green), and 0.2 short = 0.4 red + 0.36 green + 0.18 blue

The unit of the tristimulus values X, Y, and Z is often arbitrarily chosen so that Y = 1 or Y = 100 is the brightest white that a color display supports. In this case, the Y value is known as the relative luminance. The corresponding whitepoint values for X and Z can then be inferred using the standard illuminants.

LAB Lab* color space

https://en.wikipedia.org/wiki/CIELAB_color_space

  • lightness L* defines black at 0 and white at 100.
  • a* is relative to the green–magenta opponent colors, with negative values toward green and positive values toward magenta.
  • b* represents the blue–yellow opponents, with negative numbers toward blue and positive toward yellow.

The a* and b* axes are unbounded and depending on the reference white they can easily exceed ±150 to cover the human gamut. Nevertheless, software implementations often clamp these values for practical reasons. For instance, if integer math is being used it is common to clamp a* and b* in the range of −128 to 127.

CIELAB is calculated relative to a reference white, for which the CIE recommends the use of CIE Standard illuminant D65. D65 is used in the vast majority industries and applications, with the notable exception being the printing industry which uses D50.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WhiteD50 = math32.Vec3(96.4212, 100.0, 82.5188)

WhiteD50 is the standard white color used for printing industry, D50, in XYZ coordinates.

View Source
var WhiteD65 = math32.Vec3(95.047, 100.0, 108.883)

WhiteD65 is the standard white color for midday sun, D65, in XYZ coordinates. Used as a standard reference illumination condition for most cases.

Functions

func LABCompress

func LABCompress(t float32) float32

LABCompress does cube-root compression of the X, Y, Z components prior to performing the LAB conversion

func LABToXYZ

func LABToXYZ(l, a, b float32) (x, y, z float32)

LABToXYZ converts a color from L*a*b* to XYZ coordinates using the standard D65 illuminant

func LABUncompress

func LABUncompress(ft float32) float32

func LToY

func LToY(l float32) float32

LToY Converts an L* value to a Y value. L* in L*a*b* and Y in XYZ measure the same quantity, luminance. L* measures perceptual luminance, a linear scale. Y in XYZ measures relative luminance, a logarithmic scale.

func SRGB100ToLinear

func SRGB100ToLinear(r, g, b float32) (rl, gl, bl float32)

SRGB100ToLinear converts set of sRGB components to linear values, removing gamma correction. returns 100-base RGB values

func SRGBFloatToUint32

func SRGBFloatToUint32(rf, gf, bf, af float32) (r, g, b, a uint32)

SRGBFloatToUint32 converts the given non-alpha-premuntiplied sRGB float32 values to alpha-premultiplied sRGB uint32 values.

func SRGBFloatToUint8

func SRGBFloatToUint8(rf, gf, bf, af float32) (r, g, b, a uint8)

SRGBFloatToUint8 converts the given non-alpha-premuntiplied sRGB float32 values to alpha-premultiplied sRGB uint8 values.

func SRGBFromLinear

func SRGBFromLinear(rl, gl, bl float32) (r, g, b float32)

SRGBFromLinear converts set of sRGB components from linear values, adding gamma correction.

func SRGBFromLinear100

func SRGBFromLinear100(rl, gl, bl float32) (r, g, b float32)

SRGBFromLinear100 converts set of sRGB components from linear values in 0-100 range, adding gamma correction.

func SRGBFromLinearComp

func SRGBFromLinearComp(lin float32) float32

SRGBFromLinearComp converts an sRGB rgb linear component to non-linear (gamma corrected) sRGB value Used in converting from XYZ to sRGB.

func SRGBLinToXYZ

func SRGBLinToXYZ(rl, gl, bl float32) (x, y, z float32)

SRGBLinToXYZ converts sRGB linear into XYZ CIE standard color space

func SRGBToLinear

func SRGBToLinear(r, g, b float32) (rl, gl, bl float32)

SRGBToLinear converts set of sRGB components to linear values, removing gamma correction.

func SRGBToLinearComp

func SRGBToLinearComp(srgb float32) float32

SRGBToLinearComp converts an sRGB rgb component to linear space (removes gamma). Used in converting from sRGB to XYZ colors.

func SRGBToXYZ

func SRGBToXYZ(r, g, b float32) (x, y, z float32)

SRGBToXYZ converts sRGB into XYZ CIE standard color space

func SRGBToXYZ100

func SRGBToXYZ100(r, g, b float32) (x, y, z float32)

SRGBToXYZ100 converts sRGB into XYZ CIE standard color space with 100-base sRGB values -- used for CAM16 but not CAM02

func SRGBUint32ToFloat

func SRGBUint32ToFloat(r, g, b, a uint32) (fr, fg, fb, fa float32)

SRGBUint32ToFloat converts the given alpha-premultiplied sRGB uint32 values to non-alpha-premuntiplied sRGB float32 values.

func SRGBUint8ToFloat

func SRGBUint8ToFloat(r, g, b, a uint8) (fr, fg, fb, fa float32)

SRGBUint8ToFloat converts the given alpha-premultiplied sRGB uint8 values to non-alpha-premuntiplied sRGB float32 values.

func XYZ100ToSRGB

func XYZ100ToSRGB(x, y, z float32) (r, g, b float32)

XYZ100ToSRGB converts XYZ CIE standard color space, 100 base units, into sRGB

func XYZDenormD65

func XYZDenormD65(x, y, z float32) (xr, yr, zr float32)

XYZDenormD65 de-normalizes XZY values relative to the D65 outdoor white light values

func XYZNormD65

func XYZNormD65(x, y, z float32) (xr, yr, zr float32)

XYZNormD65 normalizes XZY values relative to the D65 outdoor white light values

func XYZToLAB

func XYZToLAB(x, y, z float32) (l, a, b float32)

XYZToLAB converts a color from XYZ to L*a*b* coordinates using the standard D65 illuminant

func XYZToSRGB

func XYZToSRGB(x, y, z float32) (r, g, b float32)

XYZToSRGB converts XYZ CIE standard color space into sRGB

func XYZToSRGBLin

func XYZToSRGBLin(x, y, z float32) (rl, gl, bl float32)

XYZToSRGBLin converts XYZ CIE standard color space to sRGB linear

func YToL

func YToL(y float32) float32

YToL Converts a Y value to an L* value. L* in L*a*b* and Y in XYZ measure the same quantity, luminance. L* measures perceptual luminance, a linear scale. Y in XYZ measures relative luminance, a logarithmic scale.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL