YUV To RGB

This algorithm converts YUV color space to RGB color model.



									struct RGB
{
	unsigned char R;
	unsigned char G;
	unsigned char B;
};

struct YUV
{
	double Y;
	double U;
	double V;
};

struct RGB YUVToRGB(struct YUV yuv) {
	struct RGB rgb;
	rgb.R = (unsigned char)(yuv.Y + 1.4075 * (yuv.V - 128));
	rgb.G = (unsigned char)(yuv.Y - 0.3455 * (yuv.U - 128) - (0.7169 * (yuv.V - 128)));
	rgb.B = (unsigned char)(yuv.Y + 1.7790 * (yuv.U - 128));

	return rgb;
}
								


Example

									struct YUV data = { 82, 140, 87 };
struct RGB value = YUVToRGB(data);
								


Output

									R: 24
G: 107
B: 103