#@cli rgb2oklab
#@cli : Convert color representation of selected images from RGB to Oklab.
#@cli : (see colorspace definition at: <https://bottosson.github.io/posts/oklab/> ).
#@cli : See also: ''oklab2rgb''.
rgb2oklab :
e[^-1] "Convert color representation of image$? from RGB to Oklab."
foreach {
split_opacity to_rgb[0] /[0] 255
f[0] "
l = cbrt(0.4121656120*R + 0.5362752080*G + 0.0514575653*B);
m = cbrt(0.2118591070*R + 0.6807189584*G + 0.1074065790*B);
s = cbrt(0.0883097947*R + 0.2818474174*G + 0.6302613616*B);
[ 0.2104542553*l + 0.7936177850*m - 0.0040720468*s,
1.9779984951*l - 2.4285922050*m + 0.4505937099*s,
0.0259040371*l + 0.7827717662*m - 0.8086757660*s ]"
a c
}
To transform from oklab2oklch do, use lab2lch. To find the inverse, go from lch2lab to oklab2rgb. Also remember to use srgb2rgb and rgb2srgb. I usually forget.