[vtkusers] piecewise function for volume rendering

amal / foodofheart_looly at hotmail.com
Sat Jul 12 11:57:38 EDT 2008


hi all:
vtkpiecewisetransferfunction is the function responsable for adjusting the opasity of the reconstructed volume.
i want to use this function to set the opasity of the back ground of my images to zero (transparent) so that only the part i want to see will be reconstructed.when i try to make it i find no change in the resultant volume
can anyone tells me whats wrong
my code is:
 
 
 
vtkRenderer render = new vtk.vtkRenderer();
vtkRenderWindow renwin = new vtkRenderWindow();
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
vtkBMPReader pngreader = new vtkBMPReader();
//vtkPNGReader pngreader = new vtkPNGReader();
//vtkImageReader pngreader = new vtkImageReader();
pngreader.SetFilePrefix(standardStr + "\\");
pngreader.SetFilePattern("%s%d.bmp");
//vtkImageExtractComponents extrcat = new vtkImageExtractComponents();
//extrcat.SetComponents(0);
//extrcat.SetInputConnection(pngreader.GetOutputPort());
 
 

 
 
 
 
 
 
//bmpreader.SetNumberOfScalarComponents(3);
pngreader.SetFileNameSliceOffset(1);
pngreader.SetFileNameSliceSpacing(1);
pngreader.SetDataSpacing(0.35, 0.35, 1);
pngreader.SetDataOrigin(0, 0, 0);
pngreader.SetDataExtent(0, 511, 0, 511, 0, 7);
pngreader.Update();
 

 
 

vtkPiecewiseFunction opacitytransfer = new vtkPiecewiseFunction();
opacitytransfer.ClampingOff();

opacitytransfer.AddPoint(0, 0.0);
opacitytransfer.AddPoint(255,0.0);







 

vtkColorTransferFunction colorTransferFunction =new vtkColorTransferFunction();
colorTransferFunction.AddRGBPoint(0.0,0.0,0.0,0.0);
colorTransferFunction.AddRGBPoint(64,1.0,0.0,0.0);
colorTransferFunction.AddRGBPoint(128,0.0,0.0,1.0);
colorTransferFunction.AddRGBPoint(192,0.0,1.0,0.0);
colorTransferFunction.AddRGBPoint(255.0, 0, 0.2, 0.0);
 
 
 
//vtkThreshold threshold = new vtkThreshold();
//////vtkThresholdPoints threshold = new vtkThresholdPoints();
//threshold.ThresholdBetween(15.0, 255.0);
//threshold.SetInputConnection(pngreader.GetOutputPort());
 
//vtkImageIslandRemoval2D islandremover = new vtkImageIslandRemoval2D();
//islandremover.SetAreaThreshold(4);
//islandremover.SetIslandValue(150.0);
//islandremover.SetReplaceValue(1.0);
//islandremover.SetInputConnection(threshold.GetOutputPort());



 
vtkVolumeProperty volumeproperty = new vtkVolumeProperty();
volumeproperty.SetScalarOpacity(opacitytransfer);

volumeproperty.SetColor(colorTransferFunction);

volumeproperty.ShadeOn();

vtkFixedPointVolumeRayCastMapper volumemapper = new vtkFixedPointVolumeRayCastMapper();

volumemapper.SetInput(pngreader.GetOutput());
 


vtkVolume volume = new vtkVolume();

volume.SetMapper(volumemapper);
vtkCamera acamera = new vtkCamera();
acamera.SetViewUp(0,0,-1);
acamera.SetPosition(0,1,0);
acamera.SetFocalPoint(0,0,0);
acamera.ComputeViewPlaneNormal();
 
renwin.AddRenderer(render);
iren.SetRenderWindow(renwin);
render.AddActor(volume);
render.SetActiveCamera(acamera);
render.ResetCamera();
acamera.UpdateViewport(render);
render.SetBackground(1, 1, 1);
render.GetRenderWindow().Render();
 
thanks
amal
 
 
اللهم قدرني علي من ظلمني.....لأجعل عفوى عنه
شكرا لك علي قدرتي عليه
_________________________________________________________________
The i’m Talkaton. Can 30-days of conversation change the world?
http://www.imtalkathon.com/?source=EML_WLH_Talkathon_ChangeWorld
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080712/69a0a9a1/attachment.htm>


More information about the vtkusers mailing list