Function toOklab

Converts CIE XYZ D65 to perceptual Oklab coordinates.

Oklab!T toOklab(T)(
  XyzD65!T xyz
) pure nothrow @nogc @safe;

Use this conversion before Oklab-based perceptual calculations. Extended finite values are preserved; the conversion does not clip or gamut-map them. Extreme finite XYZ inputs retain representable Oklab results where possible.

Parameters

NameDescription
xyz CIE XYZ D65 value to convert.

Returns

The corresponding Oklab value.

Standards

Uses Björn Ottosson's published Oklab XYZ/LMS/Oklab transform with the higher-precision sRGB/D65 matrix.

See Also

toXyzD65

Example

import std.math : fabs;

const xyz = XyzD65d(0.125, 0.25, 0.50);
const roundTrip = xyz.toOklab.toXyzD65;

assert(fabs(roundTrip.x - xyz.x) < 1e-12);
assert(fabs(roundTrip.y - xyz.y) < 1e-12);
assert(fabs(roundTrip.z - xyz.z) < 1e-12);