[vtkusers] vtkImageData (RGBA) only displayed in gray tones

Benjamin Ohmacht b.ohmacht at gmx.de
Fri Mar 23 05:40:19 EDT 2007


Dear VTKusers:

I'm very new in using VTK. My question is about the following code. The Code is self generated and it should display three cubes with different colors and opacity. The opacity value A is used, but the RGB values would only displayed in gray tones! What must i do to use the rgb values as color?


      //Create a DataArray for the data
      vtkUnsignedCharArray* dataArray = vtkUnsignedCharArray::New();
        dataArray->SetNumberOfComponents(4);
	dataArray->InsertNextTuple4(r, g, b, a);//is set by an external function for each voxel

   
   //Create image data
   vtkImageData* image = vtkImageData::New();
      image->SetDimensions(sizeX, sizeY, sizeZ);
      image->SetOrigin(0,0,0);
      image->SetSpacing(0.1,0.1,0.1);
      image->SetNumberOfScalarComponents(4);
      image->SetScalarTypeToUnsignedChar(); 
      image->GetPointData()->SetScalars(createData());


   vtkPiecewiseFunction* opacityTransferFunction = vtkPiecewiseFunction::New();
      opacityTransferFunction->AddPoint(0, 0.0);
      opacityTransferFunction->AddPoint(255, 1.0);


   vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();
      volumeProperty->SetScalarOpacity(opacityTransferFunction);
      volumeProperty->IndependentComponentsOff();
         

   vtkVolumeTextureMapper3D* volumeMapper = vtkVolumeTextureMapper3D::New();
      volumeMapper->SetInput(getImageData());         

   vtkVolume* volume = vtkVolume::New();
      volume->SetMapper(volumeMapper);
      volume->SetProperty(volumeProperty);

Any help is appreciated in advance!!!!

-- 
Benjamin Ohmacht<b.ohmacht at gmx.de>

"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out



More information about the vtkusers mailing list