
Added by thebman220 on May-2-2009, 4:40 am
/**
* @param integer $r : The red rgb value; must satisfy 0<=$r<256
* @param integer $g : The green rgb value; must satisfy 0<=$g<256
* @param integer $b : The blue rgb value; must satisfy 0<=$b<256
* @param boolean $digital : Whether or not the image should conform to
* ITU-R BT.709 standard (Y'CbCr) for digital
* and HDTV display. Otherwise, ITU-R BT.601/
* CCIR 601 (Y'PbPr) is used
* @return array : An array, where "y", "cb", and "cr" contain
* their respective values.
*/
function rgb2ycbcr($r,$g,$b,$digital=true) {
$Kb=$digital?0.0722:0.114;
$Kr=$digital?0.2126:0.299;
$Y=$Kr*$r+(1-$Kr-$Kb)*$g+$Kb*$b;
return array(
"y" =>round($Y),
"cb"=>round(($b-$Y)/(2*(1-$Kb))),
"cr"=>round(($r-$Y)/(2*(1-$Kr)))
);
}
Added by thebman220 on April-29-2009, 11:47 pm
Added by thebman220 on April-5-2009, 1:48 pm
Added by thebman220 on January-29-2009, 3:15 am
Added by thebman220 on January-29-2009, 3:04 am
Added by thebman220 on January-3-2009, 6:25 pm