[vtkusers] help me with vtkLookupTable

Renaud Isabelle renauisa at yahoo.fr
Thu Jan 12 14:38:04 EST 2006


Hi everyone, 
   
  I am triing to display my image data of range [-2, +2] with a colormap. 
   
  I took a look on vtkLookupTable and vtkImageMapToColors but it seems that I didn't catch vtkLookupTable notion: my displayed image is all green!!!!!
   
  Here is what I did:
   
    vtkImageReader* reader = vtkImageReader::New();
  reader->SetFileDimensionality(3); //all the slices are in one file 
  reader->SetFileName("filename.raw");
  reader->SetNumberOfScalarComponents(1); //image is greyscale 
  reader->SetDataScalarTypeToFloat(); //4 byte
  reader->SetDataExtent(0,193, 0,54, 0,164); //194 x 55 x 165 
  reader->SetDataSpacing(1.0, 194/55, 1.0);
  reader->SetDataOrigin(0.0, 0.0, 0.0);
  reader->UpdateWholeExtent();
   
  //rescaling in [0-255]
  vtkImageShiftScale* shiftScale = vtkImageShiftScale::New();
  shiftScale->SetInputConnection(reader->GetOutputPort());
  shiftScale->SetOutputScalarTypeToUnsignedChar();
   
  float min = reader->GetOutput()->GetScalarRange()[0];
  float max = reader->GetOutput()->GetScalarRange()[1];
  vtkLookupTable* table = vtkLookupTable::New();

    table->SetTableRange(min,max);
  table->SetHueRange(0.0, 0.667);//red to blue 
  table->SetSaturationRange(1.0, 1.0);
  table->SetValueRange(1.0, 1.0);
  table->SetAlphaRange (1.0, 1.0);
  table->SetNumberOfColors(256);
  table->Build();
   
  //convert to color:
  vtkImageMapToColors* colormap = vtkImageMapToColors::New();
  colormap->SetInput(shiftScale->GetOutput());
  colormap->SetLookupTable(table);
  colormap->SetOutputFormatToRGB();
   
  
  vtkImageViewer2* viewer = vtkImageViewer2::New();
  viewer->SetInput(colormap->GetOutput());
  colormap->Delete();
  reader->Delete();
   
  viewer->SetSlice(10);  
viewer->Render();

   
  Please help me. It is pretty quite urgent. 
   
  Isabelle

		
---------------------------------
 Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.Téléchargez la version beta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060112/82323c8d/attachment.htm>


More information about the vtkusers mailing list