Cleanup imlib unused methods

This commit is contained in:
Kwabena W. Agyeman 2021-03-29 10:34:09 -07:00
parent ca124aa9ca
commit dda33be809
7 changed files with 6 additions and 16546 deletions

View File

@ -99,7 +99,6 @@ SRCS += $(addprefix imlib/, \
stats.c \
template.c \
xyz_tab.c \
yuv_tab.c \
zbar.c \
)

View File

@ -93,13 +93,12 @@ void gif_add_frame(FIL *fp, image_t *img, uint16_t delay)
int block_size = IM_MIN(BLOCK_SIZE, bytes - (y*BLOCK_SIZE));
write_byte(fp, 1 + block_size);
write_byte(fp, 0x80); // clear code
uint16_t pixels[block_size];
imlib_debayer_line_to_rgb565(0, block_size, y, pixels, img);
for (int x=0; x<block_size; x++) {
int r=0, g=0, b=0;
int x_offs = ((y*BLOCK_SIZE) + x) % img->w;
int y_offs = (y*BLOCK_SIZE) / img->w;
if (x_offs > 0 && y_offs > 0 && x_offs < img->w-1 && y_offs < img->h-1) {
COLOR_BAYER_TO_RGB565(img, x_offs, y_offs, r, g, b);
}
int r = COLOR_RGB565_TO_R8(pixels[x]);
int g = COLOR_RGB565_TO_G8(pixels[x]);
int b = COLOR_RGB565_TO_B8(pixels[x]);
r >>=3; g >>=3; b >>=3;
write_byte(fp, (r<<5) | (g<<2) | b);
}

View File

@ -296,7 +296,6 @@ color_thresholds_list_lnk_data_t;
})
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>>1) * 3) + 0]
@ -311,60 +310,6 @@ extern const int8_t yuv_table[196608];
#define COLOR_LAB_TO_RGB565(l, a, b) imlib_lab_to_rgb(l, a, b)
#define COLOR_YUV_TO_RGB565(y, u, v) imlib_yuv_to_rgb((y) + 128, u, v)
#define COLOR_BAYER_TO_RGB565(img, x, y, r, g, b) \
({ \
__typeof__ (x) __x = (x); \
__typeof__ (y) __y = (y); \
if ((__y % 2) == 0) { \
if ((__x % 2) == 0) { \
r = (IM_GET_RAW_PIXEL(img, __x-1, __y-1) + \
IM_GET_RAW_PIXEL(img, __x+1, __y-1) + \
IM_GET_RAW_PIXEL(img, __x-1, __y+1) + \
IM_GET_RAW_PIXEL(img, __x+1, __y+1)) >> 2; \
\
g = (IM_GET_RAW_PIXEL(img, __x, __y-1) + \
IM_GET_RAW_PIXEL(img, __x, __y+1) + \
IM_GET_RAW_PIXEL(img, __x-1, __y) + \
IM_GET_RAW_PIXEL(img, __x+1, __y)) >> 2; \
\
b = IM_GET_RAW_PIXEL(img, __x, __y); \
} else { \
r = (IM_GET_RAW_PIXEL(img, __x, __y-1) + \
IM_GET_RAW_PIXEL(img, __x, __y+1)) >> 1; \
\
b = (IM_GET_RAW_PIXEL(img, __x-1, __y) + \
IM_GET_RAW_PIXEL(img, __x+1, __y)) >> 1; \
\
g = IM_GET_RAW_PIXEL(img, __x, __y); \
} \
} else { \
if ((__x % 2) == 0) { \
r = (IM_GET_RAW_PIXEL(img, __x-1, __y) + \
IM_GET_RAW_PIXEL(img, __x+1, __y)) >> 1; \
\
g = IM_GET_RAW_PIXEL(img, __x, __y); \
\
b = (IM_GET_RAW_PIXEL(img, __x, __y-1) + \
IM_GET_RAW_PIXEL(img, __x, __y+1)) >> 1; \
} else { \
r = IM_GET_RAW_PIXEL(img, __x, __y); \
\
g = (IM_GET_RAW_PIXEL(img, __x, __y-1) + \
IM_GET_RAW_PIXEL(img, __x, __y+1) + \
IM_GET_RAW_PIXEL(img, __x-1, __y) + \
IM_GET_RAW_PIXEL(img, __x+1, __y)) >> 2; \
\
b = (IM_GET_RAW_PIXEL(img, __x-1, __y-1) + \
IM_GET_RAW_PIXEL(img, __x+1, __y-1) + \
IM_GET_RAW_PIXEL(img, __x-1, __y+1) + \
IM_GET_RAW_PIXEL(img, __x+1, __y+1)) >> 2; \
} \
} \
r = r >> 3; \
g = g >> 2; \
b = b >> 3; \
})
#define COLOR_BINARY_TO_GRAYSCALE(pixel) ((pixel) * COLOR_GRAYSCALE_MAX)
#define COLOR_BINARY_TO_RGB565(pixel) COLOR_YUV_TO_RGB565(((pixel) ? 127 : -128), 0, 0)
#define COLOR_RGB565_TO_BINARY(pixel) (COLOR_RGB565_TO_Y(pixel) > (((COLOR_Y_MAX - COLOR_Y_MIN) / 2) + COLOR_Y_MIN))
@ -607,38 +552,9 @@ extern const int8_t kernel_gauss_5[25];
extern const int kernel_laplacian_3[9];
extern const int kernel_high_pass_3[9];
#define IM_RGB5652L(p) \
({ __typeof__ (p) _p = (p); \
lab_table[((_p>>1) * 3) + 0]; })
#define IM_RGB5652A(p) \
({ __typeof__ (p) _p = (p); \
lab_table[((_p>>1) * 3) + 1]; })
#define IM_RGB5652B(p) \
({ __typeof__ (p) _p = (p); \
lab_table[((_p>>1) * 3) + 2]; })
// Grayscale maxes
#define IM_MAX_GS (255)
// RGB565 maxes
#define IM_MAX_R5 (31)
#define IM_MAX_G6 (63)
#define IM_MAX_B5 (31)
// Grayscale histogram
#define IM_G_HIST_SIZE (256)
#define IM_G_HIST_OFFSET (0)
// LAB histogram
#define IM_L_HIST_SIZE (256)
#define IM_L_HIST_OFFSET (0)
#define IM_A_HIST_SIZE (256)
#define IM_A_HIST_OFFSET (256)
#define IM_B_HIST_SIZE (256)
#define IM_B_HIST_OFFSET (512)
#define IM_IS_BINARY(img) \
({ __typeof__ (img) _img = (img); \
_img->bpp == 0; })
@ -659,10 +575,6 @@ extern const int kernel_high_pass_3[9];
({ __typeof__ (img) _img = (img); \
_img->bpp >= 4; })
#define IM_IS_MUTABLE(img) \
({ __typeof__ (img) _img = (img); \
(_img->bpp == 1 || _img->bpp == 2); })
#define IM_X_INSIDE(img, x) \
({ __typeof__ (img) _img = (img); \
__typeof__ (x) _x = (x); \
@ -679,34 +591,6 @@ extern const int kernel_high_pass_3[9];
__typeof__ (y) _y = (y); \
((uint8_t*)_img->pixels)[(_y*_img->w)+_x]; })
#define IM_GET_RAW_PIXEL(img, x, y) \
({ __typeof__ (img) _img = (img); \
__typeof__ (x) _x = (x); \
__typeof__ (y) _y = (y); \
((uint8_t*)_img->pixels)[(_y*_img->w)+_x]; })
#define IM_GET_RAW_PIXEL_CHECK_BOUNDS_X(img, x, y) \
({ __typeof__ (img) _img = (img); \
__typeof__ (x) _x = (x); \
__typeof__ (y) _y = (y); \
_x = (_x < 0) ? 0 : (_x >= img->w) ? (img->w -1): _x; \
((uint8_t*)_img->pixels)[(_y*_img->w)+_x]; })
#define IM_GET_RAW_PIXEL_CHECK_BOUNDS_Y(img, x, y) \
({ __typeof__ (img) _img = (img); \
__typeof__ (x) _x = (x); \
__typeof__ (y) _y = (y); \
_y = (_y < 0) ? 0 : (_y >= img->h) ? (img->h -1): _y; \
((uint8_t*)_img->pixels)[(_y*_img->w)+_x]; })
#define IM_GET_RAW_PIXEL_CHECK_BOUNDS_XY(img, x, y) \
({ __typeof__ (img) _img = (img); \
__typeof__ (x) _x = (x); \
__typeof__ (y) _y = (y); \
_x = (_x < 0) ? 0 : (_x >= img->w) ? (img->w -1): _x; \
_y = (_y < 0) ? 0 : (_y >= img->h) ? (img->h -1): _y; \
((uint8_t*)_img->pixels)[(_y*_img->w)+_x]; })
#define IM_GET_RGB565_PIXEL(img, x, y) \
({ __typeof__ (img) _img = (img); \
__typeof__ (x) _x = (x); \
@ -1044,6 +928,7 @@ typedef struct imlib_draw_row_data {
typedef void (*imlib_draw_row_callback_t)(int x_start, int x_end, int y_row, imlib_draw_row_data_t *data);
// Library Hardware Init
void imlib_init_all();
void imlib_deinit_all();

File diff suppressed because it is too large Load Diff

View File

@ -182,7 +182,6 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \
stats.o \
template.o \
xyz_tab.o \
yuv_tab.o \
zbar.o \
)

View File

@ -212,7 +212,6 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \
stats.o \
template.o \
xyz_tab.o \
yuv_tab.o \
zbar.o \
)
@ -495,7 +494,6 @@ UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/sensors/, \
UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/,\
lab_tab.o \
xyz_tab.o \
yuv_tab.o \
rainbow_tab.o \
jpeg.o \
fmath.o \

View File

@ -1,33 +0,0 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# This file is part of the OpenMV project.
#
# Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
# Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
#
# This work is licensed under the MIT license, see the file LICENSE for details.
#
# This script generates RGB to YUV lookup table.
import sys
sys.stdout.write("#include <stdint.h>\n")
sys.stdout.write("const int8_t yuv_table[196608] = {\n") # 65536 * 3
for i in range(65536):
r = ((((i >> 11) & 31) * 255) + 15.5) // 31
g = ((((i >> 5) & 63) * 255) + 31.5) // 63
b = (((i & 31) * 255) + 15.5) // 31
# https://en.wikipedia.org/wiki/YCbCr (ITU-R BT.601 conversion)
y = int((r * +0.299000) + (g * +0.587000) + (b * +0.114000)) - 128;
u = int((r * -0.168736) + (g * -0.331264) + (b * +0.500000));
v = int((r * +0.500000) + (g * -0.418688) + (b * -0.081312));
sys.stdout.write(" %4d, %4d, %4d" % (y, u, v))
if (i + 1) % 4:
sys.stdout.write(", ")
elif i != 65535:
sys.stdout.write(",\n")
else:
sys.stdout.write("\n};\n")