[vtkusers] Simple color mapping question

David Doria daviddoria+vtk at gmail.com
Fri Mar 12 14:40:53 EST 2010


On Fri, Mar 12, 2010 at 2:29 PM, Johnson, Mike (IS)
<michael.l.johnson at ngc.com> wrote:
> Hi all,
>
> I have requirements to show a simple 2D surface plot where the data point
> values range, let’s say, from 0 to 100 (or might be -100 to 200 or
> whatever…) Then let’s say I want to color like this:
>
> < 20: Red
>
> 20-40: Magenta
>
> 40-60: Yellow
>
> 60-80: Blue
>
>> 80: Green
>
> Right now I have set up a vtkLookupTable and assigned 20 to red, 40 to
> magenta, 60 to yellow, and 80 to blue.  A few things –
>
> 1.      By default it appears to map as a “ramp” between the colors; ie, if
> the value is 50, it’s “magenta-yellowish.”  I’d rather just have only the 5
> colors in my map. Is this possible?
>
> 2.      Since the colors from my #1 above really specify a “range” instead
> of a “single point value” (ie, I’d like anything from 20-40 to be the same
> color), how do I specify a “less than” (for the “red” values) and a “greater
> than” (for the green values)?
>
> Thanks in advance,
> Mike Johnson

You may want to look at vtkDiscretizableColorTransferFunction:
http://www.vtk.org/Wiki/VTK/Examples/DiscretizableColorTransferFunction

Thanks,

David



More information about the vtkusers mailing list