color management: experimental CIE1931 lookup table

CIE table is better to preserve low brightness colors (original gamma table will map many low values to 0)
This commit is contained in:
Frank
2022-11-29 21:26:34 +01:00
parent 681987e52d
commit c8bc917aaf
2 changed files with 27 additions and 2 deletions

View File

@@ -320,8 +320,9 @@ uint16_t approximateKelvinFromRGB(uint32_t rgb) {
}
}
#if !defined(WLED_USE_CIE_BRIGHTNESS_TABLE)
//gamma 2.8 lookup table used for color correction
static byte gammaT[] = {
static byte gammaT[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
@@ -338,6 +339,29 @@ static byte gammaT[] = {
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
#else
// experimental
// CIE 1931 lookup table (8bit->8bit) that was proposed during discussion of issue #2767
// https://github.com/Aircoookie/WLED/issues/2767#issuecomment-1310961308
static byte gammaT[256] = {
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24,
25, 25, 26, 27, 27, 28, 28, 29, 30, 30, 31, 31, 32, 33, 33, 34,
35, 35, 36, 37, 38, 38, 39, 40, 41, 41, 42, 43, 44, 44, 45, 46,
47, 48, 49, 50, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 78,
79, 81, 82, 83, 84, 85, 87, 88, 89, 91, 92, 93, 94, 96, 97, 99,
100, 101, 103, 104, 106, 107, 109, 110, 111, 113, 115, 116, 118, 119, 121,
122, 124, 126, 127, 129, 130, 132, 134, 135, 137, 139, 141, 142, 144, 146,
148, 150, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 170, 172, 174,
177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 198, 200, 202, 204, 207,
209, 211, 213, 216, 218, 220, 223, 225, 227, 230, 232, 235, 237, 240, 242,
245, 247, 250, 252, 255 };
#endif
uint8_t gamma8_cal(uint8_t b, float gamma)
{