Oklch Colourwheel (L=0
   HOME

TheInfoList



OR:

The Oklab color space is a
uniform color space A color appearance model (CAM) is a mathematical model that seeks to describe the perceptual aspects of human color vision, i.e. viewing conditions under which the appearance of a color does not tally with the corresponding physical measurement o ...
for device independent color designed to improve perceptual uniformity,
hue In color theory, hue is one of the properties (called color appearance parameters) of a color, defined in the CIECAM02 model as "the degree to which a stimulus can be described as similar to or different from stimuli that are described as ...
and
lightness Lightness is a visual perception of the luminance (L) of an object. It is often judged relative to a similarly lit object. In colorimetry and color appearance models, lightness is a prediction of how an illuminated color will appear to a stand ...
prediction, color blending, and
usability Usability can be described as the capacity of a system to provide a condition for its users to perform the tasks safely, effectively, and efficiently while enjoying the experience. In software engineering, usability is the degree to which a softw ...
while ensuring
numerical stability In the mathematical subfield of numerical analysis, numerical stability is a generally desirable property of numerical algorithms. The precise definition of stability depends on the context: one important context is numerical linear algebra, and ...
and ease of implementation. Introduced by Björn Ottosson in December 2020, Oklab and its
cylindrical A cylinder () has traditionally been a Solid geometry, three-dimensional solid, one of the most basic of curvilinear geometric shapes. In elementary geometry, it is considered a Prism (geometry), prism with a circle as its base. A cylinder may ...
counterpart, Oklch, have been included in the
CSS Color Web colors are colors used in Web design, displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB color model, RGB triplet, in hexadecimal format (a ''hex triplet'') or acc ...
Level 4 and Level 5 drafts for device-independent
web colors Web colors are colors used in Web design, displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB color model, RGB triplet, in hexadecimal format (a ''hex triplet'') or acc ...
since December 2021. They are supported by recent versions of major
web browser A web browser, often shortened to browser, is an application for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr ...
s and allow the specification of wide-gamut P3 colors. Oklab's model is fitted with improved color appearance data: CAM16 data for lightness and chroma, and IPT data for hue. The new fit addresses issues such as unexpected hue and lightness changes in blue colors present in the
CIELAB color space The CIELAB color space, also referred to as ''L*a*b*'', is a color space defined by the International Commission on Illumination (abbreviated CIE) in 1976. It expresses color as three values: ''L*'' for perceptual lightness and ''a*'' and '' ...
, simplifying the creation of
color scheme In color theory, a color scheme is a combination of 2 or more colors used in aesthetic or practical design. Aesthetic color schemes are used to create style and appeal. Colors that create a harmonious feeling when viewed together are often u ...
s and smoother
color gradient In color science, a color gradient (also known as a color ramp or a color progression) specifies a range of position-dependent colors, usually used to fill a region. In assigning colors to a set of values, a gradient is a continuous colormap, ...
s. As Ottosson explained, he chose the name ''Oklab'' because the model does an OK (adequate) job and is based on the three color-space coordinates ''L'', ''a'', and ''b''.


Coordinates

Oklab uses the same spatial structure as CIELAB, representing color using three components: * ''L'' for perceptual lightness, ranging from 0 (pure black) to 1 (reference white, if achromatic), often denoted as a
percentage In mathematics, a percentage () is a number or ratio expressed as a fraction (mathematics), fraction of 100. It is often Denotation, denoted using the ''percent sign'' (%), although the abbreviations ''pct.'', ''pct'', and sometimes ''pc'' are ...
* ''a'' and ''b'' for opponent channels of the four
unique hues Unique hue is a term used in perceptual psychology of color vision and generally applied to the purest hues of blue, green, yellow and red. The proponents of the opponent process theory believe that these hues cannot be described as a mixture of ...
, unbounded but in practice ranging from −0.5 to +0.5; CSS assigns ±100% to ±0.4 for both ** ''a'' for green (negative) to red (positive) ** ''b'' for blue (negative) to yellow (positive) Like CIELCh, Oklch represents colors using: * ''L'' for perceptual lightness * ''C'' for chroma representing chromatic intensity, with values from 0 (achromatic) with no upper limit, but in practice not exceeding +0.5; CSS treats +0.4 as 100% * ''h'' for hue angle in a
color wheel A color wheel or color circle is an abstract illustrative organization of color hues around a circle, which shows the relationships between primary colors, secondary colors, tertiary colors etc. Some sources use the terms ''color wheel'' an ...
, typically denoted in
decimal degrees Decimal degrees (DD) is a notation for expressing latitude and longitude geographic coordinates as decimal fractions of a degree. DD are used in many geographic information systems (GIS), web mapping applications such as OpenStreetMap, and GPS ...


Achromatic colors

Neutral
grey Grey (more frequent in British English) or gray (more frequent in American English) is an intermediate color between black and white. It is a neutral or achromatic color, meaning that it has no chroma. It is the color of a cloud-covered s ...
s, pure black and the reference white are achromatic, that is, C = 0, a = 0, b = 0, and ''h'' is
undefined Undefined may refer to: Mathematics *Undefined (mathematics), with several related meanings **Indeterminate form, in calculus Computing *Undefined behavior, computer code whose behavior is not specified under certain conditions *Undefined valu ...
. Assigning any real value to their hue component has no effect on conversions between color spaces.


Color differences

The perceptual
color difference In color science, color difference or color distance is the separation between two colors. This metric allows quantified examination of a notion that formerly could only be described with adjectives. Quantification of these properties is of great ...
in Oklab is calculated as the
Euclidean distance In mathematics, the Euclidean distance between two points in Euclidean space is the length of the line segment between them. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, and therefore is o ...
between the coordinates.


Conversions between color spaces


Conversion to and from Oklch

Like CIELCh, the
Cartesian coordinates In geometry, a Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called ''coordinates'', which are the signed distances to the point from two fixed perpendicular o ...
''a'' and ''b'' are converted to the
polar coordinates In mathematics, the polar coordinate system specifies a given point (mathematics), point in a plane (mathematics), plane by using a distance and an angle as its two coordinate system, coordinates. These are *the point's distance from a reference ...
''C'' and ''h'' as follows: \begin C &= \sqrt \\ h &= \operatorname(b, a) \end And the polar coordinates are converted to the Cartesian coordinates as follows: \begin a &= C \cos(h) \\ b &= C \sin(h) \end


Conversion from CIE XYZ

Converting from CIE XYZ with a Standard Illuminant D65 involves: # Applying the
linear map In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that p ...
:
\begin l \\ m \\ s \end = \mathbf M_1 \begin X \\ Y \\ Z \end # Applying a
cube root In mathematics, a cube root of a number is a number that has the given number as its third power; that is y^3=x. The number of cube roots of a number depends on the number system that is considered. Every real number has exactly one real cub ...
non-linearity In mathematics and science, a nonlinear system (or a non-linear system) is a system in which the change of the output is not proportional to the change of the input. Nonlinear problems are of interest to engineers, biologists, physicists, mathe ...
:
\begin l' \\ m' \\ s' \end = \begin l^ \\ m^ \\ s^ \end # Converting to Oklab with another linear map:
\begin L \\ a \\ b \end = \mathbf M_2 \begin l' \\ m' \\ s' \end Given: \begin \mathbf M_1 &= \begin 0.8189330101 & \phantom0.3618667424 & -0.1288597137 \\ 0.0329845436 & \phantom0.9293118715 & \phantom0.0361456387 \\ 0.0482003018 & \phantom0.2643662691 & \phantom0.6338517070 \end \\ \mathbf M_2 &= \begin 0.2104542553 & \phantom0.7936177850 & -0.0040720468 \\ 1.9779984951 & -2.4285922050 & \phantom0.4505937099 \\ 0.0259040371 & \phantom0.7827717662 & -0.8086757660 \end \end


Conversion from sRGB

Converting from
sRGB sRGB (standard RGB) is a colorspace, for use on monitors, printers, and the World Wide Web. It was initially proposed by HP and Microsoft in 1996 and became an official standard of the International Electrotechnical Commission (IEC) as IEC 6 ...
requires first converting from sRGB to CIE XYZ with a Standard Illuminant D65. As the last step of this conversion is a linear map from linear RGB to CIE XYZ, the reference implementation directly employs the multiplied matrix representing the
composition Composition or Compositions may refer to: Arts and literature *Composition (dance), practice and teaching of choreography * Composition (language), in literature and rhetoric, producing a work in spoken tradition and written discourse, to include ...
of the two linear maps: : \begin l \\ m \\ s \end = \begin 0.4122214708 & 0.5363325363 & 0.0514459929 \\ 0.2119034982 & 0.6806995451 & 0.1073969566 \\ 0.0883024619 & 0.2817188376 & 0.6299787005 \end \begin R_\text \\ G_\text \\ B_\text \end


Conversion to CIE XYZ and sRGB

Converting to CIE XYZ and sRGB simply involves applying the respective
inverse function In mathematics, the inverse function of a function (also called the inverse of ) is a function that undoes the operation of . The inverse of exists if and only if is bijective, and if it exists, is denoted by f^ . For a function f\colon ...
s in reverse order: \begin \begin l' \\ m' \\ s' \end &= \mathbf M_2^ \begin L \\ a \\ b \end \\ \begin l \\ m \\ s \end &= \begin \left(l'\right)^3 \\ \left(m'\right)^3 \\ \left(s'\right)^3 \end \\ \begin X \\ Y \\ Z \end &= \mathbf M_1^ \begin l \\ m \\ s \end \end


Notes


References

{{Color space Color space Color appearance models 2020 introductions