|
|
|
@ -345,7 +345,70 @@ __kernel void YCrCb2RGB(__global const uchar* src, int src_step, int src_offset, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///////////////////////////////////// RGB <-> XYZ ////////////////////////////////////// |
|
|
|
|
|
|
|
|
|
__kernel void RGB2XYZ(int cols, int rows, int src_step, int dst_step, |
|
|
|
|
int bidx, __global const DATA_TYPE* src, __global DATA_TYPE* dst, |
|
|
|
|
int src_offset, int dst_offset, __constant COEFF_TYPE * coeffs) |
|
|
|
|
{ |
|
|
|
|
int dx = get_global_id(0); |
|
|
|
|
int dy = get_global_id(1); |
|
|
|
|
|
|
|
|
|
if (dy < rows && dx < cols) |
|
|
|
|
{ |
|
|
|
|
dx <<= 2; |
|
|
|
|
int src_idx = mad24(dy, src_step, src_offset + dx); |
|
|
|
|
int dst_idx = mad24(dy, dst_step, dst_offset + dx); |
|
|
|
|
|
|
|
|
|
DATA_TYPE r = src[src_idx], g = src[src_idx + 1], b = src[src_idx + 2]; |
|
|
|
|
|
|
|
|
|
#ifdef DEPTH_5 |
|
|
|
|
float x = r * coeffs[0] + g * coeffs[1] + b * coeffs[2]; |
|
|
|
|
float y = r * coeffs[3] + g * coeffs[4] + b * coeffs[5]; |
|
|
|
|
float z = r * coeffs[6] + g * coeffs[7] + b * coeffs[8]; |
|
|
|
|
#else |
|
|
|
|
int x = CV_DESCALE(r * coeffs[0] + g * coeffs[1] + b * coeffs[2], xyz_shift); |
|
|
|
|
int y = CV_DESCALE(r * coeffs[3] + g * coeffs[4] + b * coeffs[5], xyz_shift); |
|
|
|
|
int z = CV_DESCALE(r * coeffs[6] + g * coeffs[7] + b * coeffs[8], xyz_shift); |
|
|
|
|
#endif |
|
|
|
|
dst[dst_idx] = SAT_CAST(x); |
|
|
|
|
dst[dst_idx + 1] = SAT_CAST(y); |
|
|
|
|
dst[dst_idx + 2] = SAT_CAST(z); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
__kernel void XYZ2RGB(int cols, int rows, int src_step, int dst_step, |
|
|
|
|
int bidx, __global const DATA_TYPE* src, __global DATA_TYPE* dst, |
|
|
|
|
int src_offset, int dst_offset, __constant COEFF_TYPE * coeffs) |
|
|
|
|
{ |
|
|
|
|
int dx = get_global_id(0); |
|
|
|
|
int dy = get_global_id(1); |
|
|
|
|
|
|
|
|
|
if (dy < rows && dx < cols) |
|
|
|
|
{ |
|
|
|
|
dx <<= 2; |
|
|
|
|
int src_idx = mad24(dy, src_step, src_offset + dx); |
|
|
|
|
int dst_idx = mad24(dy, dst_step, dst_offset + dx); |
|
|
|
|
|
|
|
|
|
DATA_TYPE x = src[src_idx], y = src[src_idx + 1], z = src[src_idx + 2]; |
|
|
|
|
|
|
|
|
|
#ifdef DEPTH_5 |
|
|
|
|
float b = x * coeffs[0] + y * coeffs[1] + z * coeffs[2]; |
|
|
|
|
float g = x * coeffs[3] + y * coeffs[4] + z * coeffs[5]; |
|
|
|
|
float r = x * coeffs[6] + y * coeffs[7] + z * coeffs[8]; |
|
|
|
|
#else |
|
|
|
|
int b = CV_DESCALE(x * coeffs[0] + y * coeffs[1] + z * coeffs[2], xyz_shift); |
|
|
|
|
int g = CV_DESCALE(x * coeffs[3] + y * coeffs[4] + z * coeffs[5], xyz_shift); |
|
|
|
|
int r = CV_DESCALE(x * coeffs[6] + y * coeffs[7] + z * coeffs[8], xyz_shift); |
|
|
|
|
#endif |
|
|
|
|
dst[dst_idx] = SAT_CAST(b); |
|
|
|
|
dst[dst_idx + 1] = SAT_CAST(g); |
|
|
|
|
dst[dst_idx + 2] = SAT_CAST(r); |
|
|
|
|
#if dcn == 4 |
|
|
|
|
dst[dst_idx + 3] = MAX_NUM; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|