1 year ago
#203571
Adam
How to use OKLab color space?
I try to use Oklab color space with original cpp header file. My code :
#include <cstdlib> // malloc
#include <cfloat>
#include <cmath> // -lm
#include <cstdio> // printf
#include "ok_color.h" // ok_color.h : Oklab color space. A perceptual color space for image processing by 2021 Björn Ottosson
using namespace ok_color;
int main(void){
struct Lab c;
c.L = 100.0f;
c.a = 0.0f;
c.b = 0.0f;
struct RGB rgb;
rgb = oklab_to_linear_srgb(c);
//
printf("LAB : L = %.16f a = %.16f b = %.16f\n", c.L, c.a, c.b);
printf("RGB : r = %.16f g = %.16f b = %.16f\n", rgb.r, rgb.g, rgb.b);
return 0;
}
I compile it and run
g++ o.cpp -Wall -lm
./a.out
The result is :
LAB : L = 100.0000000000000000 a = 0.0000000000000000 b = 0.0000000000000000
RGB : r = 1000000.1875000000000000 g = 1000000.1250000000000000 b = 999999.93750
It is different then expected ( checked with Lch and Lab colour and gradient picker ) : rgb(255,255,255)
How should I do it ?
c++
color-space
lab-color-space
0 Answers
Your Answer