[vtkusers] Using vtkLookupTable with discrete colors and vtkTexture Problem

Donny Zimmerman zmanvortex at gmail.com
Sat May 14 14:25:46 EDT 2016


I am creating a lookup table with discrete rgba entries to map a vtkTexture
with unsigned char data to colors. When I render my scene texture is all
one color which is the last entry I put into the lookup table. Here is a
code snippet of my lookup table and texture:

vtkSmartPointer<vtkLookupTable> lookuptable =
vtkSmartPointer<vtkLookupTable>::New();
lookuptable->GetTable()->Reset();
lookuptable->SetNumberOfColors(cols->Count);

for (int tblid = 0; tblid < cols->Count; tblid++)
{
// Set the ref bin colors

double r, g, b, a;

r = cols[tblid].R / 255.0;
g = cols[tblid].G / 255.0;
b = cols[tblid].B / 255.0;

if(tblid <= 20)
{
a = 0;
}
else
{
a = cols[tblid].A / 255.0;
}

lookuptable->SetTableValue(tblid, r, g, b, a);

}

lookuptable->Build();

vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
texture->MapColorScalarsThroughLookupTableOn();
texture->SetLookupTable(lookuptable);
texture->InterpolateOff();
if(m_smooth)
{
texture->SetInputConnection(resize2->GetOutputPort());
}
else
{
texture->SetInputConnection(imgdat->GetOutputPort());
}

I have searched the documentation for vtkTexture and can't figure out what
I am doing wrong.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160514/e15a73f7/attachment.html>


More information about the vtkusers mailing list