Copyright | (c) Alexey Kuleshevich 2018-2025 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <lehins@yandex.ru> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Graphics.Color.Space.CIE1976.LAB
Description
Synopsis
- pattern LAB :: V3 e -> Color (LAB i) e
- pattern ColorLAB :: e -> e -> e -> Color (LAB i) e
- pattern ColorLABA :: e -> e -> e -> e -> Color (Alpha (LAB i)) e
- data LAB (i :: k)
- xyz2lab :: forall i a e. (Illuminant i, Elevator a, Elevator e, RealFloat e) => Color (XYZ i) a -> Color (LAB i) e
- ft :: RealFloat a => a -> a
- lab2xyz :: forall i a e. (Illuminant i, Elevator e, Elevator a, RealFloat a) => Color (LAB i) e -> Color (XYZ i) a
- ift :: (Fractional a, Ord a) => a -> a
Constructors for an CIE L*a*b* color space.
pattern ColorLABA :: e -> e -> e -> e -> Color (Alpha (LAB i)) e Source #
Constructor for LAB
with alpha channel.
CIE L*a*b* color space
It is customary to have CIELAB color channels to be in range of [0, 100], however in this library all values for consistency are kept in a [0, 1] range for floating point precision.
Conversion from XYZ
(xyz2lab
):
\[ \begin{align} L^\star &= 1.16 \ f\!\left(\frac{Y}{Y_{\mathrm{n}}}\right) - 0.16\\ a^\star &= 5.0 \left(f\!\left(\frac{X}{X_{\mathrm{n}}}\right) - f\!\left(\frac{Y}{Y_{\mathrm{n}}}\right)\right)\\ b^\star &= 2.0 \left(f\!\left(\frac{Y}{Y_{\mathrm{n}}}\right) - f\!\left(\frac{Z}{Z_{\mathrm{n}}}\right)\right) \end{align} \]
Where ft
is defined as:
\[ \begin{align} f(t) &= \begin{cases} \sqrt[3]{t} & \text{if } t > \delta^3 \\ \dfrac{t}{3 \delta^2} + \frac{4}{29} & \text{otherwise} \end{cases} \\ \delta &= \tfrac{6}{29} \end{align} \]
\[ \begin{align} X &= X_{\mathrm{n}} f^{-1}\left(\frac{L^\star+0.16}{1.16} + \frac{a^\star}{5.0}\right)\\ Y &= Y_{\mathrm{n}} f^{-1}\left(\frac{L^\star+0.16}{1.16}\right)\\ Z &= Z_{\mathrm{n}} f^{-1}\left(\frac{L^\star+0.16}{1.16} - \frac{b^\star}{2.0}\right)\\ \end{align} \]
Where ift
is defined as:
\[ f^{-1}(t) = \begin{cases} t^3 & \text{if } t > \delta \\ 3\delta^2\left(t - \tfrac{4}{29}\right) & \text{otherwise} \end{cases} \]
Instances
Helpers
XYZ to L*a*b*
xyz2lab :: forall i a e. (Illuminant i, Elevator a, Elevator e, RealFloat e) => Color (XYZ i) a -> Color (LAB i) e Source #
L*a*b* to XYZ
lab2xyz :: forall i a e. (Illuminant i, Elevator e, Elevator a, RealFloat a) => Color (LAB i) e -> Color (XYZ i) a Source #
ift :: (Fractional a, Ord a) => a -> a Source #