/* Pixel Color Conversion (RGB to YUV) (10 points) The pixels on your monitor are typically represented in RGB color space. The letters stand for Red, Green, and Blue. The colors are encoded with three numbers, one for each color. The most popular format uses three integers in the range from 0 to 255 (8-bit color). Here are some examples of popular colors and their RGB representations: R G B // Name ======================== 0 0 0 // black 255 0 0 // red 0 255 0 // green 0 0 255 // blue 0 0 128 // navy blue 255 255 0 // yellow 165 42 42 // brown 255 255 255 // white An alternative color representation that is sometimes useful for computer vision applicaitons is YUV. Here is how to convert from RGV to YUV: Y = 0.299R + 0.587G + 0.114B U = 0.492 (B-Y) V = 0.877 (R-Y) [Source: http://www.pcmag.com/encyclopedia_term/0,2542,t=YUVRGB+conversion+formulas&i=55166,00.asp] [See also http://en.wikipedia.org/wiki/YUV ] Write a complete C program that reads in 3 numbers representing the three colors (R, G, and B) and outputs the corresponding YUV colors. */ #include #include int main(int argc, char* argv[]) { int R, G,B; double Y, U, V; printf("Enter R: "); scanf("%d", &R); printf("Enter G: "); scanf("%d", &G); printf("Enter B: "); scanf("%d", &B); Y = 0.299*R + 0.587*G + 0.114*B; U = 0.492*(B-Y); V = 0.877*(R-Y); printf("[%3d, %3d, %3d] in RGB is equal to [%.3f, %.3f, %.3f] in YUV \n\n", R,G,B, Y,U,V); system("pause"); }