color

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package color holds go-gfx's colour helpers. Its first concern is premultiplied alpha: filtering, blending or interpolating straight-alpha pixels lets a transparent pixel's (arbitrary) colour leak into the visible result — the dark or pale fringe around a resized cut-out. Multiplying each colour channel by its alpha first, operating, then dividing back out removes that leak. resample uses these for its Bilinear and Box premultiplied paths; the bicubic and Lanczos paths premultiply in float64 inside the kernel.

Index

Constants

This section is empty.

Variables

View Source
var D50 = WhitePoint{X: 0.96422, Y: 1.0, Z: 0.82521}

D50 is the CIE Standard Illuminant D50 (horizon light, ~5003 K) for the 2-deg observer — the connection-space white of ICC profiles and the reference white CSS Color 4 uses for Lab/LCH.

View Source
var D65 = WhitePoint{X: 0.95047, Y: 1.0, Z: 1.08883}

D65 is the CIE Standard Illuminant D65 (noon daylight, ~6504 K) for the 2-deg observer — the white point sRGB, Rec.709 and Display-P3 are defined against.

View Source
var Rec601Luma = [3]float64{0.213, 0.715, 0.072}

Rec601Luma is the Rec. 601 luminance coefficients (0.213, 0.715, 0.072) that the Filter Effects spec fixes for saturate() and hue-rotate().

View Source
var Rec709Luma = [3]float64{0.2126, 0.7152, 0.0722}

Rec709Luma is the Rec. 709 luminance coefficients (0.2126, 0.7152, 0.0722) that the Filter Effects spec fixes for grayscale().

Functions

func CMYKToSRGB added in v0.4.0

func CMYKToSRGB(c CMYK) (r, g, b float64)

CMYKToSRGB converts a naive CMYK colour back to gamma-encoded sRGB, the inverse of SRGBToCMYK up to the black-recovery rounding.

func Clamp01 added in v0.4.0

func Clamp01(c float64) float64

Clamp01 clamps a channel value to the unit range [0, 1].

func ClampRGB added in v0.4.0

func ClampRGB(r, g, b float64) (float64, float64, float64)

ClampRGB clamps each channel of an RGB triple to [0, 1] independently. This is the crudest gamut mapping: it can shift hue, but never leaves the cube.

func DecodeGamma added in v0.4.0

func DecodeGamma(c, gamma float64) float64

DecodeGamma decodes a gamma-encoded channel value c (>= 0) back to linear light with a pure power-law of exponent gamma, returning c**gamma, the inverse of EncodeGamma.

func DeltaE76 added in v0.4.0

func DeltaE76(a, b Lab) float64

DeltaE76 is the CIE 1976 colour difference: the Euclidean distance between two L*a*b* colours.

func DeltaE94 added in v0.4.0

func DeltaE94(ref, sample Lab) float64

DeltaE94 is the CIE 1994 colour difference with the graphic-arts weighting (kL = kC = kH = 1, K1 = 0.045, K2 = 0.015). The metric is asymmetric: ref is the reference (standard) colour and sample the trial colour.

func DeltaE2000 added in v0.4.0

func DeltaE2000(c1, c2 Lab) float64

DeltaE2000 is the CIEDE2000 colour difference between two L*a*b* colours, with the standard weighting factors kL = kC = kH = 1. It follows the reference formulation of Sharma, Wu and Dalal (2005).

func DeltaEOK added in v0.4.0

func DeltaEOK(a, b OKLab) float64

DeltaEOK is the OKLab colour difference: the Euclidean distance between two OKLab colours. Because OKLab is perceptually near-uniform this is a simple yet well-behaved metric.

func EncodeGamma added in v0.4.0

func EncodeGamma(c, gamma float64) float64

EncodeGamma encodes a linear-light channel value c (>= 0) with a pure power-law of exponent gamma, returning c**(1/gamma).

func HSLToSRGB added in v0.4.0

func HSLToSRGB(h HSL) (r, g, b float64)

HSLToSRGB converts an HSL colour back to gamma-encoded sRGB, the inverse of SRGBToHSL.

func HSVToSRGB added in v0.4.0

func HSVToSRGB(h HSV) (r, g, b float64)

HSVToSRGB converts an HSV colour back to gamma-encoded sRGB, the inverse of SRGBToHSV.

func HWBToSRGB added in v0.4.0

func HWBToSRGB(h HWB) (r, g, b float64)

HWBToSRGB converts an HWB colour back to gamma-encoded sRGB, the inverse of SRGBToHWB. When whiteness and blackness together fill or overflow the range the result is the achromatic grey W/(W+B).

func InGamut added in v0.4.0

func InGamut(r, g, b, eps float64) bool

InGamut reports whether every channel of an RGB triple lies within [0, 1] to within eps, i.e. whether the colour is displayable without gamut mapping. Pass eps = 0 for an exact test or a small value (e.g. 1e-6) to absorb rounding.

func LCHToSRGB added in v0.4.0

func LCHToSRGB(c LCH) (r, g, b float64)

LCHToSRGB converts an LCh(ab) colour under D65 back to gamma-encoded sRGB.

func LabToSRGB added in v0.3.0

func LabToSRGB(l Lab) (r, g, b float64)

LabToSRGB converts a CIE L*a*b* colour to gamma-encoded sRGB (each channel 0..1, not clamped to gamut), the inverse of SRGBToLab.

func LinearToSRGB added in v0.3.0

func LinearToSRGB(c float64) float64

LinearToSRGB converts one linear-light channel value (0..1) to its sRGB encoding, the inverse of SRGBToLinear.

func LuvToSRGB added in v0.4.0

func LuvToSRGB(l Luv) (r, g, b float64)

LuvToSRGB converts a CIE L*u*v* colour under D65 back to gamma-encoded sRGB (not clamped to gamut), the inverse of SRGBToLuv.

func NormalizeHue added in v0.4.0

func NormalizeHue(h float64) float64

NormalizeHue folds a hue angle in degrees into the canonical range [0, 360), handling negative angles and multiples of 360. It is applied inside the hue-based inverses, but is exported for callers building hues arithmetically.

func OKLCHToSRGB added in v0.4.0

func OKLCHToSRGB(c OKLCH) (r, g, b float64)

OKLCHToSRGB converts an OKLCH colour back to gamma-encoded sRGB (not clamped to gamut), the inverse of SRGBToOKLCH.

func OKLabToLinearRGB added in v0.4.0

func OKLabToLinearRGB(c OKLab) (r, g, b float64)

OKLabToLinearRGB converts an OKLab colour to linear-light sRGB primaries (each 0..1 for in-gamut colour), the inverse of LinearRGBToOKLab.

func OKLabToSRGB added in v0.4.0

func OKLabToSRGB(c OKLab) (r, g, b float64)

OKLabToSRGB converts an OKLab colour to gamma-encoded sRGB (each channel 0..1, not clamped to gamut), the inverse of SRGBToOKLab.

func Premultiply

func Premultiply(src []uint8) []uint8

Premultiply returns a new slice of the straight-alpha RGBA pixels src with each colour channel multiplied by its alpha (rounded to nearest), alpha left unchanged. len(src) must be a multiple of four.

func QuantizeUnitToByte added in v0.4.0

func QuantizeUnitToByte(v float64) uint8

QuantizeUnitToByte clamps a channel value to [0, 1] and quantises it to an 8-bit value using round-half-to-even, matching scikit-image's img_as_ubyte (numpy.rint). It is the quantisation step image-level consumers apply after SkimageLabToSRGB / SkimageXYZToSRGB to reproduce scikit-image byte output.

func SRGBToLinear added in v0.3.0

func SRGBToLinear(c float64) float64

SRGBToLinear converts one sRGB-encoded channel value (0..1) to linear light using the IEC 61966-2-1 electro-optical transfer function.

func Shade added in v0.6.0

func Shade(c color.RGBA, factor float64) color.RGBA

Shade returns c with its gamma-encoded sRGB R, G, B channels multiplied by factor and rounded to the nearest 8-bit value, clamping the result to [0, 255]; alpha is preserved unchanged. A factor below 1 darkens the colour and a factor above 1 lightens it; a negative factor is treated as 0 (black).

This is the diffuse-shading primitive an isometric renderer uses to derive a solid's per-face colours from one base colour: the top face is drawn at factor 1, and the side faces at progressively smaller factors so a lit solid reads with depth. Multiplying the encoded channels (rather than adapting lightness in a perceptual space) reproduces the flat, banded look of the pixel-art isometric convention and is what makes the three faces of a cube distinguishable by a constant ratio.

func SkimageLabToSRGB added in v0.4.0

func SkimageLabToSRGB(l Lab) (r, g, b float64)

SkimageLabToSRGB converts a CIELAB colour to gamma-encoded sRGB (each channel 0..1, not quantised, not gamut-clamped), reproducing skimage.color.lab2rgb before its byte conversion. Inverse of SkimageSRGBToLab.

func SkimageXYZToLinearRGB added in v0.4.0

func SkimageXYZToLinearRGB(c XYZ) (r, g, b float64)

SkimageXYZToLinearRGB converts CIE XYZ to linear-light sRGB primaries using scikit-image's inverse matrix, the inverse of SkimageLinearRGBToXYZ.

func SkimageXYZToSRGB added in v0.4.0

func SkimageXYZToSRGB(c XYZ) (r, g, b float64)

SkimageXYZToSRGB converts CIE XYZ to gamma-encoded sRGB (each channel 0..1, not quantised), reproducing skimage.color.xyz2rgb (the inverse matrix then forward companding), the inverse of SkimageSRGBToXYZ.

func UnpremultiplyInPlace

func UnpremultiplyInPlace(pix []uint8)

UnpremultiplyInPlace divides the colour channels of premultiplied RGBA pixels back out of their alpha, in place, rounding to nearest and clamping to [0, 255]. A fully transparent pixel (alpha 0) is left black. It is the inverse of Premultiply up to rounding. len(pix) must be a multiple of four.

func XYZToLinearRGB added in v0.3.0

func XYZToLinearRGB(c XYZ) (r, g, b float64)

XYZToLinearRGB converts CIE XYZ to linear-light sRGB primaries using the inverse sRGB D65 matrix (values may fall outside [0, 1] for out-of-gamut colours).

func YCbCr601ToSRGB added in v0.4.0

func YCbCr601ToSRGB(c YCbCr) (r, g, b float64)

YCbCr601ToSRGB converts full-range BT.601 Y'CbCr back to gamma-encoded sRGB, the inverse of SRGBToYCbCr601.

func YCbCr709ToSRGB added in v0.4.0

func YCbCr709ToSRGB(c YCbCr) (r, g, b float64)

YCbCr709ToSRGB converts full-range BT.709 Y'CbCr back to gamma-encoded sRGB, the inverse of SRGBToYCbCr709.

Types

type BlendMode added in v0.3.0

type BlendMode int

BlendMode names a separable blend mode from the W3C Compositing and Blending Level 1 specification. A separable mode blends each colour channel independently: given a backdrop channel Cb and a source channel Cs (both in [0, 1]) it produces the blended channel B(Cb, Cs). BlendMode.Blend evaluates the mode; the formulas match the specification exactly so the results equal the published reference values.

const (
	// Normal returns the source unchanged (B = Cs); the default painting mode.
	Normal BlendMode = iota
	// Multiply multiplies backdrop and source (B = Cb*Cs); the result is never
	// lighter than either input.
	Multiply
	// Screen is the inverse-multiply complement (B = Cb + Cs - Cb*Cs); never
	// darker than either input.
	Screen
	// Overlay multiplies or screens depending on the backdrop; it is HardLight
	// with the operands swapped.
	Overlay
	// Darken keeps the darker channel (B = min(Cb, Cs)).
	Darken
	// Lighten keeps the lighter channel (B = max(Cb, Cs)).
	Lighten
	// ColorDodge brightens the backdrop toward white in proportion to the
	// source.
	ColorDodge
	// ColorBurn darkens the backdrop toward black in proportion to the source.
	ColorBurn
	// HardLight multiplies or screens depending on the source; it is Overlay
	// with the operands swapped.
	HardLight
	// SoftLight is a gentler HardLight, softening rather than clipping at the
	// extremes.
	SoftLight
	// Difference is the absolute channel difference (B = |Cb - Cs|).
	Difference
	// Exclusion is a lower-contrast Difference (B = Cb + Cs - 2*Cb*Cs).
	Exclusion
)

func (BlendMode) Blend added in v0.3.0

func (m BlendMode) Blend(cb, cs float64) float64

Blend returns the blended channel value B(cb, cs) for the mode, with backdrop cb and source cs each in [0, 1]. An unrecognised mode falls back to Normal.

type CMYK added in v0.4.0

type CMYK struct{ C, M, Y, K float64 }

CMYK is a naive device CMYK colour, each of cyan, magenta, yellow and the black key in [0, 1].

func SRGBToCMYK added in v0.4.0

func SRGBToCMYK(r, g, b float64) CMYK

SRGBToCMYK converts a gamma-encoded sRGB colour (each channel 0..1) to naive CMYK. Pure black maps to K == 1 with zero coloured ink.

type ColorMatrix added in v0.5.0

type ColorMatrix [3][4]float64

ColorMatrix is a 3x4 colour transform applied to a gamma-encoded sRGB colour: three rows of [cr cg cb offset]. An output channel is cr*R + cg*G + cb*B + offset, with R, G, B and the offset in [0, 1]; alpha is not touched by these operations, so it is not part of the matrix. A consumer working in another numeric range (e.g. 0..255 bytes) scales the offset by its full-scale value.

func BrightnessMatrix added in v0.5.0

func BrightnessMatrix(a float64) ColorMatrix

BrightnessMatrix is CSS brightness(a): a per-channel linear multiply by a (a >= 0, may exceed 1). It is a scale, not the additive brightness of an image-processing "adjust brightness".

func GrayscaleMatrix added in v0.5.0

func GrayscaleMatrix(a float64) ColorMatrix

GrayscaleMatrix is CSS grayscale(a): the saturation matrix at s = 1-a with Rec. 709 luma, so a interpolates from the original (a = 0) towards full luminance grey (a = 1).

func HueRotateMatrix added in v0.5.0

func HueRotateMatrix(rad float64) ColorMatrix

HueRotateMatrix is CSS hue-rotate(rad) / SVG feColorMatrix type="hueRotate": a rotation of the colour about the luminance axis by rad radians, built from the fixed constant, cosine and sine matrices of the Filter Effects spec.

func InvertMatrix added in v0.5.0

func InvertMatrix(a float64) ColorMatrix

InvertMatrix is CSS invert(a): each channel interpolates towards its negative by a, out = (1-2a)*in + a. a = 1 is a full photographic negative.

func SaturateMatrix added in v0.5.0

func SaturateMatrix(s float64) ColorMatrix

SaturateMatrix is CSS saturate(s) / SVG feColorMatrix type="saturate": the saturation matrix at factor s with Rec. 601 luma. s may exceed 1.

func SepiaMatrix added in v0.5.0

func SepiaMatrix(a float64) ColorMatrix

SepiaMatrix is CSS sepia(a): a = 1 is full sepia tone, a = 0 is identity.

func (ColorMatrix) Apply added in v0.5.0

func (m ColorMatrix) Apply(r, g, b float64) (float64, float64, float64)

Apply transforms one gamma-encoded sRGB colour (channels in [0, 1]) by m, returning the three output channels unclamped (a saturation or hue rotation can push a channel slightly outside [0, 1]; the caller clamps to its range).

type HSL added in v0.4.0

type HSL struct{ H, S, L float64 }

HSL is a colour in the hue/saturation/lightness cylinder of gamma-encoded sRGB. H is in degrees [0, 360); S and L are in [0, 1].

func SRGBToHSL added in v0.4.0

func SRGBToHSL(r, g, b float64) HSL

SRGBToHSL converts a gamma-encoded sRGB colour (each channel 0..1) to HSL.

type HSV added in v0.4.0

type HSV struct{ H, S, V float64 }

HSV is a colour in the hue/saturation/value cylinder of gamma-encoded sRGB. H is in degrees [0, 360); S and V are in [0, 1].

func SRGBToHSV added in v0.4.0

func SRGBToHSV(r, g, b float64) HSV

SRGBToHSV converts a gamma-encoded sRGB colour (each channel 0..1) to HSV.

type HWB added in v0.4.0

type HWB struct{ H, W, B float64 }

HWB is a colour in the hue/whiteness/blackness model of gamma-encoded sRGB. H is in degrees [0, 360); W and B are in [0, 1].

func SRGBToHWB added in v0.4.0

func SRGBToHWB(r, g, b float64) HWB

SRGBToHWB converts a gamma-encoded sRGB colour (each channel 0..1) to HWB.

type LCH added in v0.4.0

type LCH struct{ L, C, H float64 }

LCH is a colour in a cylindrical CIE space: L is lightness, C is chroma (radial) and H is the hue angle in degrees [0, 360). It represents both LCh(ab) (from Lab) and LCh(uv) (from Luv); which one is fixed by the conversion that produced it.

func LabToLCH added in v0.4.0

func LabToLCH(l Lab) LCH

LabToLCH converts CIE L*a*b* to its cylindrical form LCh(ab).

func LuvToLCH added in v0.4.0

func LuvToLCH(l Luv) LCH

LuvToLCH converts CIE L*u*v* to its cylindrical form LCh(uv).

func SRGBToLCH added in v0.4.0

func SRGBToLCH(r, g, b float64) LCH

SRGBToLCH converts a gamma-encoded sRGB colour to LCh(ab) under D65.

type Lab added in v0.3.0

type Lab struct{ L, A, B float64 }

Lab is a colour in the CIE L*a*b* space: L* is lightness (0 black .. 100 diffuse white), a* is the green(-)/red(+) axis and b* the blue(-)/yellow(+) axis.

func LCHToLab added in v0.4.0

func LCHToLab(c LCH) Lab

LCHToLab converts cylindrical LCh(ab) back to CIE L*a*b*, the inverse of LabToLCH.

func SRGBToLab added in v0.3.0

func SRGBToLab(r, g, b float64) Lab

SRGBToLab converts an sRGB colour (each channel 0..1, gamma-encoded) to CIE L*a*b*, chaining sRGB->linear->XYZ->Lab.

func SkimageSRGBToLab added in v0.4.0

func SkimageSRGBToLab(r, g, b float64) Lab

SkimageSRGBToLab converts a gamma-encoded sRGB colour to CIELAB, reproducing skimage.color.rgb2lab (rgb2xyz composed with xyz2lab). Because it uses scikit-image's matrix and white together, pure white maps to Lab (100, -0.00245, 0.00465), exactly as scikit-image does.

func SkimageXYZToLab added in v0.4.0

func SkimageXYZToLab(c XYZ) Lab

SkimageXYZToLab converts CIE XYZ to CIELAB relative to the D65 white, matching skimage.color.xyz2lab (its constants and reference white).

func XYZToLab added in v0.3.0

func XYZToLab(c XYZ) Lab

XYZToLab converts CIE XYZ (D65) to CIE L*a*b*.

func XYZToLabWP added in v0.4.0

func XYZToLabWP(c XYZ, wp WhitePoint) Lab

XYZToLabWP converts CIE XYZ to CIE L*a*b* relative to the white point wp.

type Luv added in v0.4.0

type Luv struct{ L, U, V float64 }

Luv is a colour in CIE 1976 L*u*v*: L is lightness (0..100) and u*, v* are the chromatic axes.

func LCHToLuv added in v0.4.0

func LCHToLuv(c LCH) Luv

LCHToLuv converts cylindrical LCh(uv) back to CIE L*u*v*, the inverse of LuvToLCH.

func SRGBToLuv added in v0.4.0

func SRGBToLuv(r, g, b float64) Luv

SRGBToLuv converts a gamma-encoded sRGB colour to CIE L*u*v* under D65.

func XYZToLuv added in v0.4.0

func XYZToLuv(c XYZ) Luv

XYZToLuv converts CIE XYZ (D65) to CIE L*u*v*.

func XYZToLuvWP added in v0.4.0

func XYZToLuvWP(c XYZ, wp WhitePoint) Luv

XYZToLuvWP converts CIE XYZ to CIE L*u*v* relative to the white point wp.

type OKLCH added in v0.4.0

type OKLCH struct{ L, C, H float64 }

OKLCH is the cylindrical form of OKLab: L is lightness (0..1), C is chroma and H is the hue angle in degrees [0, 360).

func OKLabToOKLCH added in v0.4.0

func OKLabToOKLCH(c OKLab) OKLCH

OKLabToOKLCH converts OKLab to its cylindrical form OKLCH.

func SRGBToOKLCH added in v0.4.0

func SRGBToOKLCH(r, g, b float64) OKLCH

SRGBToOKLCH converts a gamma-encoded sRGB colour to OKLCH.

type OKLab added in v0.4.0

type OKLab struct{ L, A, B float64 }

OKLab is a colour in Ottosson's OKLab space: L is lightness (0..1), A is the green(-)/red(+) axis and B the blue(-)/yellow(+) axis.

func LinearRGBToOKLab added in v0.4.0

func LinearRGBToOKLab(r, g, b float64) OKLab

LinearRGBToOKLab converts linear-light sRGB primaries (each 0..1) to OKLab.

func OKLCHToOKLab added in v0.4.0

func OKLCHToOKLab(c OKLCH) OKLab

OKLCHToOKLab converts cylindrical OKLCH back to OKLab, the inverse of OKLabToOKLCH.

func SRGBToOKLab added in v0.4.0

func SRGBToOKLab(r, g, b float64) OKLab

SRGBToOKLab converts a gamma-encoded sRGB colour (each channel 0..1) to OKLab.

type RGB added in v0.4.0

type RGB struct{ R, G, B float64 }

RGB is a gamma-encoded sRGB triple with each channel in [0, 1], the operand of the non-separable blend modes.

func BlendColor added in v0.4.0

func BlendColor(cb, cs RGB) RGB

BlendColor is the W3C Color blend: the hue and saturation of the source with the luminosity of the backdrop.

func BlendHue added in v0.4.0

func BlendHue(cb, cs RGB) RGB

BlendHue is the W3C Hue blend: the hue of the source with the saturation and luminosity of the backdrop.

func BlendLuminosity added in v0.4.0

func BlendLuminosity(cb, cs RGB) RGB

BlendLuminosity is the W3C Luminosity blend: the luminosity of the source with the hue and saturation of the backdrop.

func BlendSaturation added in v0.4.0

func BlendSaturation(cb, cs RGB) RGB

BlendSaturation is the W3C Saturation blend: the saturation of the source with the hue and luminosity of the backdrop.

type WhitePoint added in v0.4.0

type WhitePoint struct{ X, Y, Z float64 }

WhitePoint is a reference white in CIE 1931 XYZ, its luminance Y normalised to 1. It is the illuminant a device-independent colour space is measured against.

type XYZ added in v0.3.0

type XYZ struct{ X, Y, Z float64 }

XYZ is a colour in the CIE 1931 XYZ space (D65-referenced here). Y is luminance; for in-gamut linear sRGB the components lie roughly in [0, 1].

func Adapt added in v0.4.0

func Adapt(c XYZ, src, dst WhitePoint) XYZ

Adapt returns the CIE XYZ colour c, measured under illuminant src, expressed under illuminant dst using the Bradford chromatic-adaptation transform. When src == dst the colour is returned unchanged up to floating-point rounding.

func AdaptD50ToD65 added in v0.4.0

func AdaptD50ToD65(c XYZ) XYZ

AdaptD50ToD65 carries a CIE XYZ colour from the D50 white point to D65.

func AdaptD65ToD50 added in v0.4.0

func AdaptD65ToD50(c XYZ) XYZ

AdaptD65ToD50 carries a CIE XYZ colour from the D65 white point to D50.

func LabToXYZ added in v0.3.0

func LabToXYZ(l Lab) XYZ

LabToXYZ converts CIE L*a*b* back to CIE XYZ (D65), the inverse of XYZToLab.

func LabToXYZWP added in v0.4.0

func LabToXYZWP(l Lab, wp WhitePoint) XYZ

LabToXYZWP converts CIE L*a*b* back to CIE XYZ relative to the white point wp, the inverse of XYZToLabWP.

func LinearRGBToXYZ added in v0.3.0

func LinearRGBToXYZ(r, g, b float64) XYZ

LinearRGBToXYZ converts linear-light sRGB primaries (each 0..1) to CIE XYZ using the standard sRGB D65 matrix.

func LuvToXYZ added in v0.4.0

func LuvToXYZ(l Luv) XYZ

LuvToXYZ converts CIE L*u*v* back to CIE XYZ (D65), the inverse of XYZToLuv.

func LuvToXYZWP added in v0.4.0

func LuvToXYZWP(l Luv, wp WhitePoint) XYZ

LuvToXYZWP converts CIE L*u*v* back to CIE XYZ relative to the white point wp, the inverse of XYZToLuvWP.

func SkimageLabToXYZ added in v0.4.0

func SkimageLabToXYZ(l Lab) XYZ

SkimageLabToXYZ converts CIELAB back to CIE XYZ, matching skimage.color .lab2xyz — including its clip of a negative Z in f-space, applied BEFORE the inverse nonlinearity rather than after it. Inverse of SkimageXYZToLab.

func SkimageLinearRGBToXYZ added in v0.4.0

func SkimageLinearRGBToXYZ(r, g, b float64) XYZ

SkimageLinearRGBToXYZ converts linear-light sRGB primaries to CIE XYZ using scikit-image's matrix (skimage.color rgb2xyz without the companding step).

func SkimageSRGBToXYZ added in v0.4.0

func SkimageSRGBToXYZ(r, g, b float64) XYZ

SkimageSRGBToXYZ converts a gamma-encoded sRGB colour (each channel 0..1) to CIE XYZ, reproducing skimage.color.rgb2xyz (inverse companding then the scikit-image matrix).

type YCbCr added in v0.4.0

type YCbCr struct{ Y, Cb, Cr float64 }

YCbCr is a full-range Y'CbCr colour: Y is luma in [0, 1]; Cb and Cr are the blue- and red-difference chroma in [0, 1], neutral at 0.5.

func SRGBToYCbCr601 added in v0.4.0

func SRGBToYCbCr601(r, g, b float64) YCbCr

SRGBToYCbCr601 converts a gamma-encoded sRGB colour to full-range Y'CbCr with ITU-R BT.601 (SDTV) luma weights.

func SRGBToYCbCr709 added in v0.4.0

func SRGBToYCbCr709(r, g, b float64) YCbCr

SRGBToYCbCr709 converts a gamma-encoded sRGB colour to full-range Y'CbCr with ITU-R BT.709 (HDTV) luma weights.

Jump to

Keyboard shortcuts

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