RGB2YCbCr RGB2Gray


Y = 0.2990R+0.5870G+0.1140B;                       
Cb=-0.1687R-0.3313G+0.5000B+128;                 
Cr= 0.5000R-0.4187G-0.0813B+128;

 

RGB  --> YCbCr

// |Y   |    |16  |                    |65.738   129.057  25.06 |   |R|
// |Cb| = |128| + (1/256)*   |-37.945  -74.494  112.43| *|G|

// |Cr |    |128|                   |112.439  -94.154  -18.28|   |B|

 

Y = 0.256789*R + 0.504129*G + 0.097906*B + 16

Cb = -0.148223*R  - 0.290992*G +  0.439215*B + 128

Cr = 0.439215*R - 0.367789*G - 0.071426*B + 128

YCbCr --> RGB

//|R|                      |298.082    0                408.58 |          |Y   -16  |
//|G|   =   (1/256)*|298.082    -100.291    -208.12|    *     |Cb-128|
//|B|                      |298.082    516.411     0          |          |Cr -128|

R = 1.164383*(y-16) + 0 + 1.596027*(v - 128)

G = 1.164383*(y- 16) - 0.391762*(u - 128) - 0.812969*(v - 128)

B = (1.164383*(y- 16) + 2.017230*(u - 128) + 0

 

 

RGB --> gray

Gray = 0.299 * red + 0.587 * green + 0.114 * blue;

posted on 2013-07-24 14:29  wps712  阅读(762)  评论(0编辑  收藏  举报

导航