Table of Contents

Struct LabColor

Namespace
LMKit.Graphics.Primitives
Assembly
LM-Kit.NET.dll

A color expressed in the CIE 1976 Lab* space (CIELAB) under the D65 illuminant, the perceptually uniform space every color comparison in the SDK is made in. L runs from 0 (black) to 100 (diffuse white); A runs from green (negative) to red (positive) and B from blue (negative) to yellow (positive), both nominally within [-128, 127] for colors an sRGB display can show.

public readonly struct LabColor : IEquatable<LabColor>
Implements
Inherited Members

Remarks

Conversions follow IEC 61966-2-1 for the sRGB transfer curve and the CIE definitions for XYZ and L*a*b*, with the D65 reference white (0.95047, 1.00000, 1.08883). DeltaE2000(LabColor) implements the CIEDE2000 color-difference formula (Sharma, Wu and Dalal, 2005), the current CIE recommendation, whose unit is one just-noticeable difference.

The struct is immutable and allocation-free; the sRGB decoding table is built once per process.

Constructors

LabColor(double, double, double)

Creates a CIELAB color from its three coordinates.

Fields

A

Green (negative) to red (positive) opponent axis.

B

Blue (negative) to yellow (positive) opponent axis.

L

Lightness, 0 (black) to 100 (white).

Properties

Chroma

Chroma: the distance from the neutral axis, sqrt(a² + b²). Zero is a pure gray; sRGB primaries reach roughly 100-130.

Hue

Hue angle in degrees within [0, 360): the direction of the color on the ab plane (red near 40°, yellow near 100°, green near 140°, blue near 300°). Undefined for a neutral color, reported as 0.

Methods

DeltaE2000(LabColor)

The CIEDE2000 color difference to other: roughly, 1 is the smallest difference a trained observer notices, 2-3 is visible at a glance, 10 and beyond reads as a different color.

DeltaE2000(LabColor, LabColor)

The CIEDE2000 color difference between two colors, with the standard parametric weights (kL = kC = kH = 1). Implements the formula as laid out in Sharma, Wu and Dalal, "The CIEDE2000 color-difference formula: Implementation notes, supplementary test data, and mathematical observations" (2005), including the hue-difference and mean-hue conventions the paper settles.

Equals(LabColor)
Equals(object)
FromColor32(Color32)

Converts an 8-bit sRGB color to CIELAB (D65). Alpha is ignored.

FromRgb(byte, byte, byte)

Converts 8-bit sRGB components to CIELAB (D65).

GetHashCode()
ToColor32()

Converts back to an opaque 8-bit sRGB color. Coordinates outside the sRGB gamut clip per channel, so the result is always displayable.

ToString()

Operators

operator ==(LabColor, LabColor)

Equality operator.

operator !=(LabColor, LabColor)

Inequality operator.

Share