mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Fix XYZ lookup
This commit is contained in:
parent
2706b0c41b
commit
2ba464310e
@ -54,12 +54,12 @@
|
|||||||
|
|
||||||
#define MAX_GRAY_LEVEL (255)
|
#define MAX_GRAY_LEVEL (255)
|
||||||
|
|
||||||
|
/* XYZ lookup table */
|
||||||
|
extern const float xyz_table[256];
|
||||||
/* RGB565->LAB lookup */
|
/* RGB565->LAB lookup */
|
||||||
extern const int8_t lab_table[196608];
|
extern const int8_t lab_table[196608];
|
||||||
/* Grayscale [0..255] to rainbox lookup */
|
/* Grayscale [0..255] to rainbox lookup */
|
||||||
extern const uint16_t rainbow_table[256];
|
extern const uint16_t rainbow_table[256];
|
||||||
/* XYZ lookup table */
|
|
||||||
extern const float xyz_table[256];
|
|
||||||
|
|
||||||
uint32_t imlib_lab_distance(struct color *c0, struct color *c1)
|
uint32_t imlib_lab_distance(struct color *c0, struct color *c1)
|
||||||
{
|
{
|
||||||
@ -95,16 +95,9 @@ void imlib_rgb_to_lab(struct color *rgb, struct color *lab)
|
|||||||
float xyz[3];
|
float xyz[3];
|
||||||
const float c1 = 16.0f/ 116.0f;
|
const float c1 = 16.0f/ 116.0f;
|
||||||
|
|
||||||
for (int i=0; i<3; i++) {
|
v[0] = xyz_table[rgb->vec[0]];
|
||||||
t = rgb->vec[i]/255.0f;
|
v[1] = xyz_table[rgb->vec[1]];
|
||||||
if (t > 0.04045f) {
|
v[2] = xyz_table[rgb->vec[2]];
|
||||||
t = xyz_table[rgb->vec[i]];
|
|
||||||
} else {
|
|
||||||
t/= 1292.0f;
|
|
||||||
}
|
|
||||||
v[i]=t;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
xyz[0] = (v[0] * 0.4124f + v[1] * 0.3576f + v[2] * 0.1805f) / 95.047f ;
|
xyz[0] = (v[0] * 0.4124f + v[1] * 0.3576f + v[2] * 0.1805f) / 95.047f ;
|
||||||
xyz[1] = (v[0] * 0.2126f + v[1] * 0.7152f + v[2] * 0.0722f) / 100.0f ;
|
xyz[1] = (v[0] * 0.2126f + v[1] * 0.7152f + v[2] * 0.0722f) / 100.0f ;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user