mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Use interpolated LAB table.
* Saves about 100KBs.
This commit is contained in:
parent
eccaeb111b
commit
690a39c0cb
@ -274,13 +274,13 @@ color_thresholds_list_lnk_data_t;
|
||||
(__rb_pixel * 0x0801) + ((__pixel << 3) & 0x7E0); \
|
||||
})
|
||||
|
||||
extern const int8_t lab_table[196608];
|
||||
extern const int8_t lab_table[196608/2];
|
||||
extern const int8_t yuv_table[196608];
|
||||
|
||||
#ifdef IMLIB_ENABLE_LAB_LUT
|
||||
#define COLOR_RGB565_TO_L(pixel) lab_table[(pixel) * 3]
|
||||
#define COLOR_RGB565_TO_A(pixel) lab_table[((pixel) * 3) + 1]
|
||||
#define COLOR_RGB565_TO_B(pixel) lab_table[((pixel) * 3) + 2]
|
||||
#define COLOR_RGB565_TO_L(pixel) lab_table[((pixel>>1) * 3) + 0]
|
||||
#define COLOR_RGB565_TO_A(pixel) lab_table[((pixel>>1) * 3) + 1]
|
||||
#define COLOR_RGB565_TO_B(pixel) lab_table[((pixel>>1) * 3) + 2]
|
||||
#else
|
||||
#define COLOR_RGB565_TO_L(pixel) imlib_rgb565_to_l(pixel)
|
||||
#define COLOR_RGB565_TO_A(pixel) imlib_rgb565_to_a(pixel)
|
||||
@ -596,15 +596,15 @@ extern const int kernel_high_pass_3[9];
|
||||
|
||||
#define IM_RGB5652L(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
lab_table[_p * 3]; })
|
||||
lab_table[((_p>>1) * 3) + 0]; })
|
||||
|
||||
#define IM_RGB5652A(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
lab_table[(_p * 3) + 1]; })
|
||||
lab_table[((_p>>1) * 3) + 1]; })
|
||||
|
||||
#define IM_RGB5652B(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
lab_table[(_p * 3) + 2]; })
|
||||
lab_table[((_p>>1) * 3) + 2]; })
|
||||
|
||||
// Grayscale maxes
|
||||
#define IM_MAX_GS (255)
|
||||
|
||||
24578
src/omv/imlib/lab_tab.c
24578
src/omv/imlib/lab_tab.c
File diff suppressed because it is too large
Load Diff
@ -13,10 +13,12 @@
|
||||
def lin(c):
|
||||
return 100 * ((c/12.92) if (c<=0.04045) else pow((c+0.055)/1.055, 2.4))
|
||||
|
||||
import sys
|
||||
import sys, math
|
||||
sys.stdout.write("#include <stdint.h>\n")
|
||||
|
||||
sys.stdout.write("const int8_t lab_table[196608] = {\n") # 65536 * 3
|
||||
l_list = []
|
||||
a_list = []
|
||||
b_list = []
|
||||
sys.stdout.write("const int8_t lab_table[98304] = {\n") # 65536 * 3 / 2
|
||||
for i in range(65536):
|
||||
|
||||
r = ((((i >> 11) & 31) * 255) + 15.5) // 31
|
||||
@ -45,10 +47,17 @@ for i in range(65536):
|
||||
a = int(round(500 * (x-y)));
|
||||
b = int(round(200 * (y-z)));
|
||||
|
||||
sys.stdout.write(" %4d, %4d, %4d" % (l, a, b))
|
||||
l_list.append(int(round(116 * y)) - 16)
|
||||
a_list.append(int(round(500 * (x-y))))
|
||||
b_list.append(int(round(200 * (y-z))))
|
||||
|
||||
lab = list(zip(l_list, a_list, b_list))
|
||||
for i, (x, y) in enumerate(zip(lab[0::2], lab[1::2])):
|
||||
out = [(i1 + i2)/2.0 for i1, i2 in zip(x, y)]
|
||||
sys.stdout.write(" %4d, %4d, %4d" % (out[0], out[1], out[2]))
|
||||
if (i + 1) % 4:
|
||||
sys.stdout.write(", ")
|
||||
elif i != 65535:
|
||||
elif i != 65535//2:
|
||||
sys.stdout.write(",\n")
|
||||
else:
|
||||
sys.stdout.write("\n};\n")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user