40 likes | 200 Vues
This project presents an implementation of RGB to YUV color conversion, aiming to facilitate the understanding of color space transformations in digital imaging. Developed by 林孟諭 from the Dept. of Electrical Engineering, National Cheng Kung University, Taiwan, the code efficiently processes each pixel of an input frame, converting RGB values to YUV components. This conversion is crucial in various applications, including video processing and image enhancement. Key equations are implemented in C, demonstrating the computational aspects of color space conversion.
E N D
RGB to YUV CDFG 林孟諭 Dept. of Electrical Engineering National Cheng Kung University Tainan, Taiwan, R.O.C
C program void main(void) {int a, b, c; … RGB_2_YCrCb( I_Frame, O_Frame); … } void RGB_2_YCrCb (I_Frame, O_Frame) { inty, cb, cr; for each pixel (a, b, c) in I_Frame do { y =0.257*a + 0.504*b + 0.098*c + 16; cb = -0.148*a -0.291*b + 0.439*c + 128; cr = 0.439*a -0.368*b -0.071*c + 128; write (y, cr, cb) to O_Frame; } } // Y: black-white component, UV: color differences
Single Operation description begin Py= a* 0.257; // 1 Qy= b* 0.504; // 2 Ry= c* 0.098; // 3 Sy= Ry+ 16; // 4 Ty= Py+ Qy; // 5 y = Sy+ Ty; // 6 Pcb= a* -0.148; // 7 Qcb= b* -0.291; // 8 Rcb= c* 0.439; // 9 Scb= Rcb+ 128; // 10 Tcb= Pcb+ Qcb; // 11 cb = Scb+ Tcb; // 12 Pcr= a* 0.439; // 13 Qcr= b* -0.368; // 14 Rcr= c* -0.071; // 15 Scr= Rcr+ 128; // 16 Tcr= Pcr+ Qcr; // 17 cr = Scr+ Tcr; // 18 end
CDFG b a c 128 a 0.257 b 0.504 c 0.098 16 a -0.148 b -0.291 c 0.439 a 0.439 b -0.368 c -0.071 128 * * * * * * * * * Py Qy Ry Pcb Qcb Rcb Pcr Qcr Rcr + + + + + + Ty Tcb Tcr Sy Scb Scr + + + y cb cr