[vtkusers] Setting specific colors to vtkPolyData

Miri Trope miritrope at gmail.com
Sat Jan 14 18:08:24 EST 2012


Hi David,
Thank you for your answer, I'd appreciate a further advice:

I managed to map the right values (scalars) into the right colors (green,
yellow and red).
However, I haven't found the method to get the color gradients in each
color range.
I mean that I'd like to obtain the scalars data (which have been mapped to
those three colors) into the gradient of each color.
Thus, I should get something like a topological map.

Here is my code snippet:

    vtk_lut->SetNumberOfColors(3);
    vtk_lut->Build();
    vtk_lut->SetTableValue(2,0,1,0); //green
    vtk_lut->SetTableValue(1,1,1,0); //yellow
    vtk_lut->SetTableValue(0,1,0,0); //red

If it possible, please represent in which functions I should use.
Thanks in advance!


On Thu, Jan 12, 2012 at 3:18 PM, David Doria <daviddoria at gmail.com> wrote:

> On Thu, Jan 12, 2012 at 2:47 AM, Miri Trope <miritrope at gmail.com> wrote:
> > Hi David,
> >
> > I'd like to get a colored surface with three colors like a traffic light:
> > green  -  (which represents  low values)
> > orange -  (which represents  middle values)
> > red     -   (which represents high values)
> >
> > each of those values should get its brightness due to the value its
> range.
> > for example:
> > lets say that my vtkFloatArray consists of six elements s.t.:
> >   [5,2,1,6,4,1]
> > -divide the elements to three groups and normalized each value s.t:
> > lighter    (LI)     color x {green,orange,red}
> > stronger (ST)    color x { " }
> >   [LI red, ST green, LI green, ST red, ST orange, LI green]
> >
> > Hope that now my question is clearer.
> > Thanks in advance :-)
>
> I'd suggest you insert the colors in the color map as HSV values. I
> don't think there is direct support for doing this, but you can
> convert them manually.
>
> You'll want to end up with something like:
>
> ColorMap = { {H_g, S_g, V_light}, {H_g, S_g, V_dark}, {H_o, S_o,
> V_light}, {H_o, S_o, V_dark}, {H_r, S_r, V_light}, {H_r, S_r, V_dark}
> }
>
> That is, choose a green hue (H_g), a green saturation (S_g), hues for
> orange and red, and then the values of "light" and "dark" you want.
>
> But you'll have to insert them as RGB values. You can convert the HSV
> values to choose to RGB using functions from vtkMath
> (
> http://www.vtk.org/doc/nightly/html/classvtkMath.html#a432c7d56d981a3030cb0d6f4a8789b79
> )
> such as vtkMath::HSVToRGB.
>
> For reference:
> http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV
>
> Good luck,
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120115/cc3587ab/attachment.htm>


More information about the vtkusers mailing list