[vtkusers] Using vtkPiecewiseFunction and vtkColorTransferFunction

Prename Surname bsd.diverse at gmail.com
Sat Oct 14 09:01:50 EDT 2006


Hello. I seem to have a small problem using the functions
vtkPiecewiseFunction and vtkColorTransferFunction.

I have a very simple mask consisting of values
background=-2949120
foreground= 2949030

I just want to visualize this volume in vtk. I have defined the
vtkPiecewiseFunction and vtkColorTransferFunction like this:

 unsigned short bg=-2949120;
unsigned short fg= 2949030;

//Create transfer mapping scalar value to color
vtkPiecewiseFunction *opacityTransferfunction=vtkPiecewiseFunction::New();
vtkColorTransferFunction
*colorTransferFunction=vtkColorTransferFunction::New();

opacityTransferfunction->AddPoint(bg,0.0);
opacityTransferfunction->AddPoint(fg,1.0);

colorTransferFunction->AddRGBPoint(bg,0.0,0.0,0.0);
colorTransferFunction->AddRGBPoint(fg,1.,1.,1.);
But when i then run the program, the volume is just rendered as one solid
gray cube. All I want to is to visualize the foreground in a certain color,
and not show the background.
How do i do that? Am i missing something?
Many regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061014/327d7d3e/attachment.htm>


More information about the vtkusers mailing list