[vtkusers] vtkColorTransferFunction and vtkDataArray

Matthieu.Chabanas at imag.fr Matthieu.Chabanas at imag.fr
Thu May 22 04:08:37 EDT 2003


Hello,

I would like to map scalars to colors using a non-continuous linear function, 
let's say :
yellow if x is in [min, a]
orange if x is in [a,b]
red if x is in [b,max]

I found an old mail (01 Aug 2001) in the user list that suggests using 
vtkColorTransferFunction :

> Hello Ron,
> 
> You should be able to use vtkColorTransferFunction for this (it is a 
> subclass of vtkScalarsToColors just as vtkLookupTable is). Let e be some 
> small epsilon value, min be the minimum value in your scalar range and max 
> be the maximum - then you would do the following
> 
> ctf = vtkColorTransferFunction::New();
> ctf->AddRGBPoint( min, r1, g1, b1 );
> ctf->AddRGBPoint( a-e, r1, g1, b1 );
> ctf->AddRGBPoint(   a, r2, g2, b2 );
> ctf->AddRGBPoint(   b, r2, g2, b2 );
> ctf->AddRGBPoint( b+e, r3, g3, b3 );
> ctf->AddRGBPoint( max, r3, g3, b3 );
> 
> This would set all values below a to (r1, g1, b1), those between a and b to 
> (r2, g2, b2) and those above b to (r3, g3, b3).
> 
> The problem you are having with vtkLookupTable is that the scalar value is 
> implied from the number of entries and the scalar range. With 
> vtkColorTransferFunction you have more control.
> 
> 
> Lisa
> 


This sounds exactly what I need. 
The question is: how can I link this transfer function with scalars in a 
vtkDataArray?
There is the SetLookupTable method, but it can only be used with a 
vtkLookupTable, not a vtkColorTransferFunction.
Is it possible to build a vtkLookupTable that has the same behaviour as a 
vtkColorTransferFunction?

Thanks for any help
Matt





-------------------------------------------------
envoyé via Webmail/IMAG !




More information about the vtkusers mailing list