[vtkusers] Scalar color / LookupTable / Interpolation problem...

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Thu Apr 29 17:50:01 EDT 2004


Hi Ingo,
  I think this is the same problem reported some time ago:
      http://public.kitware.com/pipermail/vtkusers/2001-October/008306.html
and I have seen this myself. After peeking inside the code a bit I came to
the following understanding (maybe wrong):  vtk passes 'per vertex'
colours, which it gets from a lookup table, to OpenGL, which then
interpolates colours across polygon faces as part of its lighting
calculations. So OpenGL will shade red to green producing yellow along the
way which is not in your lookup table!

If this is so then I dont see any definitive solution, OpenGL would have to
know about the vtk lookup table to do the right thing.

I might be able to give you a solution... I have been developing a class
that maps scalar values to discrete colours. The benefits were: it gives
contours 'for free'; and values can be interpreted easily on a scalar bar,
especially with just a few colours (~10). But now I think about it, this
class will not suffer from the problem you are having. The red-green edge
will definately have black in the middle, In fact I tested exactly this a
while back!, see attached image. The image also illustrates a problem with
the scalar bar that you could help me diagnose... so do you want me to send
the code?

  Dave P

(See attached file: LUTWithLines.jpg)



|---------+---------------------------->
|         |           "de Boer Ingo"   |
|         |           <I.deBoer at polytec|
|         |           .de>             |
|         |           Sent by:         |
|         |           vtkusers-admin at vt|
|         |           k.org            |
|         |                            |
|         |                            |
|         |           30/04/2004 04:27 |
|         |                            |
|---------+---------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                |
  |       To:       <vtkusers at vtk.org>                                                                                             |
  |       cc:                                                                                                                      |
  |       Subject:  [vtkusers] Scalar color / LookupTable / Interpolation problem...                                               |
  >--------------------------------------------------------------------------------------------------------------------------------|




Hi all,

I have a problem regarding of the interpolation
of the elements and lookup tables...

I have a lookup table from -10 to 10
whereas -10 is red and 10 is green, 0 is black

Now I have a triangle like this:

red                              green
  x (-10)   ----------------      x (10)

           \                /
            \              /
                  x (0)
                  black

>From red to black it is okay. From black
to green it is also okay.
Now, the interpolation from the red edge
to the green egde does not include any
black...It seems that VTK does some RGB
interpolation instead of using my lookup
table...

What do I do wrong ?
I set my scalar value -10,10,0 to each point, than

// create color lookup table
m_pvtkLookupTable->SetNumberOfColors(m_lPaletteEntries);

// build palette
m_pvtkLookupTable->Build();
long lCounter = 0;
for (int i = 0; i < m_lPaletteEntries; i++)
{
  float fRed   = (float) r[lCounter] / 255.0f;
  float fGreen = (float) g[lCounter] / 255.0f;
  float fBlue  = (float) g[lCounter] / 255.0f;
  m_pvtkLookupTable->SetTableValue(i, fRed, fGreen, fBlue, 1.0);
}

// set to mapper
pvtkPolyDataMapper->SetLookupTable(pvtkLookupTable);
pvtkPolyDataMapper->SetScalarRange(0, lPaletteEntries-1);

The color of each edge point is correct...

Do I need more ?
Do I need a special interpolation method ?

greets
  Ingo

---
Dr.-Ing. Ingo H. de Boer

Polytec GmbH
Polytec-Platz 1-7, 76337 Waldbronn, Germany
phone: ++49 7243 604 106
fax  : ++49 7243 604 255

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

_


-------------- next part --------------
A non-text attachment was scrubbed...
Name: LUTWithLines.jpg
Type: image/jpeg
Size: 21560 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040430/b45ea1f5/attachment.jpg>


More information about the vtkusers mailing list