mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Move image kernels to imlib.c
This commit is contained in:
parent
41d5171b95
commit
7b3d2d931e
@ -17,24 +17,9 @@ typedef struct gvec {
|
||||
uint16_t g;
|
||||
} gvec_t;
|
||||
|
||||
static const int8_t kernel_high_pass_33[] = {
|
||||
-1, -1, -1,
|
||||
-1, +8, -1,
|
||||
-1, -1, -1
|
||||
};
|
||||
|
||||
static const int8_t kernel_gauss_55[] = {
|
||||
2, 4, 5, 4, 2,
|
||||
4, 9, 12, 9, 4,
|
||||
5, 12, 15, 12, 5,
|
||||
4, 9, 12, 9, 4,
|
||||
2, 4, 5, 4, 2,
|
||||
};
|
||||
|
||||
|
||||
void imlib_edge_simple(image_t *src, rectangle_t *roi, int low_thresh, int high_thresh)
|
||||
{
|
||||
imlib_morph(src, 1, kernel_high_pass_33, 1.0f, 0.0f);
|
||||
imlib_morph(src, 1, kernel_high_pass_3, 1.0f, 0.0f);
|
||||
simple_color_t lt = {.G=low_thresh};
|
||||
simple_color_t ht = {.G=high_thresh};
|
||||
imlib_binary(src, 1, <, &ht, false);
|
||||
@ -48,7 +33,7 @@ void imlib_edge_canny(image_t *src, rectangle_t *roi, int low_thresh, int high_t
|
||||
gvec_t *gm = fb_alloc0(src->w*src->h*sizeof*gm);
|
||||
|
||||
//1. Noise Reduction with a 5x5 Gaussian filter
|
||||
imlib_morph(src, 2, kernel_gauss_55, 1.0f/159.0f, 0.0f);
|
||||
imlib_morph(src, 2, kernel_gauss_5, 1.0f/159.0f, 0.0f);
|
||||
|
||||
//2. Finding Image Gradients
|
||||
for (int y=roi->y+1; y<roi->y+roi->h-1; y++) {
|
||||
|
||||
@ -24,6 +24,33 @@ extern const float xyz_table[256];
|
||||
// RGB565 to YUV conversion
|
||||
extern const int8_t yuv_table[196608];
|
||||
|
||||
const int8_t kernel_gauss_3[3*3] = {
|
||||
9, 12, 9,
|
||||
12, 15, 12,
|
||||
9, 12, 9,
|
||||
};
|
||||
|
||||
const int8_t kernel_gauss_5[5*5] = {
|
||||
2, 4, 5, 4, 2,
|
||||
4, 9, 12, 9, 4,
|
||||
5, 12, 15, 12, 5,
|
||||
4, 9, 12, 9, 4,
|
||||
2, 4, 5, 4, 2,
|
||||
};
|
||||
|
||||
const int8_t kernel_laplacian_3[3*3] = {
|
||||
-1, -1, -1,
|
||||
-1, 8, -1,
|
||||
-1, -1, -1
|
||||
};
|
||||
|
||||
const int8_t kernel_high_pass_3[3*3] = {
|
||||
-1, -1, -1,
|
||||
-1, +8, -1,
|
||||
-1, -1, -1
|
||||
};
|
||||
|
||||
|
||||
// USE THE LUT FOR RGB->LAB CONVERSION - NOT THIS FUNCTION!
|
||||
void imlib_rgb_to_lab(simple_color_t *rgb, simple_color_t *lab)
|
||||
{
|
||||
|
||||
@ -84,6 +84,12 @@ extern const uint8_t g826_table[256];
|
||||
// RGB565 to LAB conversion
|
||||
extern const int8_t lab_table[196608];
|
||||
|
||||
// Image kernels
|
||||
extern const int8_t kernel_gauss_3[9];
|
||||
extern const int8_t kernel_gauss_5[25];
|
||||
extern const int8_t kernel_laplacian_3[9];
|
||||
extern const int8_t kernel_high_pass_3[9];
|
||||
|
||||
#define IM_RGB5652L(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
lab_table[_p * 3]; })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user