lab2rgb

Syntax

int lab2rgb(int l, int a, int b, int z)

Arguments

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

Return

Returns the red, green or blue value depending on the value of z

Description

Lets you convert Lab values to RGB 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;
}

See Also

rgb2lab

Comments

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