[vtkusers] vtkLookupTable displaying different colors in each run.
the lily
the.1.lily at hotmail.com
Fri Aug 22 14:30:52 EDT 2014
Hi Everyone,
I'm trying to set the lookup-table to give me blue for the minimum and red for the maximum value with linear interpolation between them.
When I run my program it gives me different colors each time. Here is my code, can anyone help me to figure out what I'm doing wrong?
vtkLookupTable *lut = vtkLookupTable::New();lut->SetNumberOfTableValues(256);vtkColorTransferFunction *TF = vtkColorTransferFunction::New();TF->SetColorSpaceToDiverging();TF->AddRGBPoint(reader->GetOutput()->GetScalarRange()[0],0.0,0.0,1.0);TF->AddRGBPoint(reader->GetOutput()->GetScalarRange()[1],1.0,0.0,0.0); TF->SetScaleToLinear();
double myValue; for(int i=0; i<256;i++) { myValue = GetLinearInterploation(i/1.0,0, 256, reader->GetOutput()->GetScalarRange()[0], reader->GetOutput()->GetScalarRange()[1]); lut->SetTableValue(myValue,TF->GetColor(myValue)); }
lut->Build();SliceMapper->SetLookupTable(lut);SliceMapper->SetScalarRange(reader->GetOutput()->GetScalarRange()[0],reader->GetOutput()->GetScalarRange()[1]);vtkRenderer *ren = vtkRenderer::New();vtkRenderWindow *renwin = vtkRenderWindow::New();renwin->AddRenderer(ren); ren->AddActor(SliceActor);vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renwin);renwin->Render();iren->Start();
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140822/3d7ca53f/attachment.html>
More information about the vtkusers
mailing list