[vtkusers] How to color all the object with LookupTable?

UkrPost leon_tol at yahoo.com
Thu Sep 27 19:02:02 EDT 2001


Hi,
I'm using VTK to read the image (gray-level), then wrap it, and then
color to different colors according to the gray-level of the pixels.
But as the result i have all the object with one color (red for
example..). How to assign colors to  all the range of values ?
And how can i find out what exactly was the gray-level of the pixel?
This is part of my program:



--------------------------------

  vtkBMPReader *image = vtkBMPReader::New();
        image->SetFileName( "d:/VTKsample/simp/test.bmp" );
//to transform from vtkStructuredPoints to vtkPolyData
  vtkStructuredPointsGeometryFilter *geometry = vtkStructuredPointsGeometryFilter::New();
        geometry->SetInput( image->GetOutput() );
//form the elevation
  vtkWarpScalar *warp = vtkWarpScalar::New();
        warp->SetInput( geometry->GetOutput());
        float ScaleFactor = 0.1;//scalars from 0 up to 25.5
        warp->SetScaleFactor(ScaleFactor);
        cout << "Form the elevation ...." << endl;
//set lookup table
//  vtkWindowLevelLookupTable *wl = vtkWindowLevelLookupTable::New();
  vtkLookupTable *lut = vtkLookupTable::New();
//      lut->SetNumberOfColors(256);
//      lut->SetHueRange(100,200);
//      lut->SetValueRange(15,25.5);
//      lut->SetRange(0,25.5); // may be this one will work ?
        lut->SetTableRange(0,25.5);
//      lut->Build();
        

  vtkElevationFilter *colorIt = vtkElevationFilter::New();
    colorIt->SetInput(warp->GetOutput()); 
//    colorIt->SetLowPoint(0,0,0);
//    colorIt->SetHighPoint(0,0,255*ScaleFactor);


//receive PolyData 
  vtkPolyDataMapper *mapper     = vtkPolyDataMapper::New();
//      mapper->SetInput( warp->GetPolyDataOutput() );
        mapper->SetInput( colorIt->GetPolyDataOutput() );
        mapper->SetColorModeToMapScalars();
        mapper->SetScalarRange(0,255*ScaleFactor); // to map scalars into lookup table
        mapper->ImmediateModeRenderingOff();
        mapper->SetLookupTable(lut);
// set actor
  vtkActor *actor = vtkActor::New();
        actor->SetMapper( mapper );

// create a rendering window and renderer and interactor
  vtkRenderer *ren = vtkRenderer::New();
  vtkRenderWindow *renWindow = vtkRenderWindow::New();
    renWindow->AddRenderer( ren );
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
        iren->SetRenderWindow( renWindow );
        renWindow->SetSize( 600, 600 );
// add actor to the render
ren->AddActor( actor );
ren->SetBackground(0.5,0.4,0.7);
renWindow->Render();
//initialize  or START ? begin the event loop
iren->Start();

-------------------------------
As the result i see the wrapped object , but it has only one color...
If anybody knows how to fix it , please let me know!
Thanks in advance for any answer,
WBR,
Leon


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




More information about the vtkusers mailing list