ycbcr2rgb

Syntax

int ycbcr2rgb(int y, int cb, int cr, int z)

Arguments

y
Red value
cb
Green value
cr
Blue value
z
Determines which value is returned. z=0 for red, z=1 for green, z=2 for blue

Return

Returns the red, gree or blue value from 0 to 255 depending on the value of z

Description

Lets you convert YCbCr values to RGB values.

Example

%ffp

ctl(0):"Y (Luminancy)",Range=(-255,255),val=0
ctl(1):"Cb (Chroma Blue)",Range=(-255,255),val=0
ctl(2):"Cr (Chroma Red)",Range=(-255,255),val=0


ForEveryTile:{
	int r,g,b,i,cb,cr;


		for (y= y_start; y < y_end; y++){
			if(updateProgress(y,y_end)) abort();
		for (x = x_start; x < x_end; x++){
				
			r = src(x,y,0);
			g = src(x,y,1);
			b = src(x,y,2);

			i = rgb2ycbcr (r,g,b,0);
			cb = rgb2ycbcr (r,g,b,1); 
			cr =rgb2ycbcr (r,g,b,2); 
			
			
			//Do the adjustment
			i = i + ctl(0);
			cb = cb + ctl(1);
			cr = cr + ctl(2);

			pset( x, y, 0, ycbcr2rgb (i,cb,cr,0) );
			pset( x, y, 1, ycbcr2rgb (i,cb,cr,1) );
			pset( x, y, 2, ycbcr2rgb (i,cb,cr,2) );
			

		}}

	return true;

}

Also see

rgb2ycbcr

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.