YUV To RGB
This algorithm converts YUV color space to RGB color model.
class RGB
{
public $R;
public $G;
public $B;
}
class YUV
{
public $Y;
public $U;
public $V;
}
function YUVToRGB($yuv) {
$rgb = new RGB();
$rgb->R = floor($yuv->Y + 1.4075 * ($yuv->V - 128));
$rgb->G = floor($yuv->Y - 0.3455 * ($yuv->U - 128) - (0.7169 * ($yuv->V - 128)));
$rgb->B = floor($yuv->Y + 1.7790 * ($yuv->U - 128));
return $rgb;
}
Example
$data = new YUV();
$data->Y = 82;
$data->U = 140;
$data->V = 87;
$value = YUVToRGB($data);
Output
R: 24
G: 107
B: 103