rgb2lab

Syntax

int rgb2lab(int r, int g, int b, int z)

Arguments

r
Red value
g
Green value
b
Blue value
z
Determines which value is returned. z=0 for L, z=1 for a, z=2 for b

Return

Returns the L, a or b value from 0 to 255 depending on the value of z

Description

Lets you convert RGB values to Lab values.

Example

%ffp

ctl(0):"L Adjust",Range=(-255,255),val=0
ctl(1):"a Adjust",Range=(-255,255),val=0
ctl(2):"b Adjust",Range=(-255,255),val=0

ForEveryTile:{
		
		int r,g,b,l,a,b2;

		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);

			l = rgb2lab (r,g,b,0);
			a = rgb2lab (r,g,b,1); 
			b2 = rgb2lab (r,g,b,2); 			

			//Do the Lab adjustment
			l = l + ctl(0);
			a = a + ctl(1);
			b2 = b2 + ctl(2);

			r = lab2rgb (l,a,b2,0);
			g = lab2rgb (l,a,b2,1);
			b = lab2rgb (l,a,b2,2);

			pset( x, y, 0, r );
			pset( x, y, 1, g );
			pset( x, y, 2, b );

		}}

	return true;
}

Also see

lab2rgb

Comments

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