[vtkusers] volume color transferfunction help needed

Sarah Saeed sosca7 at hotmail.com
Mon Mar 14 05:23:08 EDT 2011




hello everyone, please i need help in adjusting the transferfunctions , i got a dark volume and i googled for a suitable transferfunstions but i could find any,so please can anyone help me?
here's the code i wrote:
 
vtkDICOMImageReader Reader = new vtkDICOMImageReader();
Reader.SetDirectoryName(FolderName);
Reader.Update();
double[] ImageRange = new double[2];
ImageRange = Reader.GetOutput().GetScalarRange();
 
vtkImageShiftScale ScaleFunc = new vtkImageShiftScale();
ScaleFunc.SetInputConnection(Reader.GetOutputPort());
ScaleFunc.SetShift(-1.0 * ImageRange[0]);
ScaleFunc.SetScale(255.0 / (ImageRange[1] - ImageRange[0]));
ScaleFunc.SetOutputScalarTypeToUnsignedChar();
ScaleFunc.Update();
vtkImageData ImageData = new vtkImageData();
ImageData = ScaleFunc.GetOutput();
int[] Dimension = new int[3];
Dimension = ImageData.GetDimensions();
/////
vtkImageGaussianSmooth smooth = new vtkImageGaussianSmooth();
smooth.SetDimensionality(3);//three dimensional gaussian is performed. 
smooth.SetRadiusFactors(1, 1, 1);
smooth.SetStandardDeviation(3, 3, 3);//Sets the Standard deviation of the gaussian in pixel units.
smooth.SetInput(ImageData);
vtkPiecewiseFunction opacitytransfer = new vtkPiecewiseFunction();//control the opacity of voxels
opacitytransfer.ClampingOff();
opacitytransfer.AddPoint(84, 0);
opacitytransfer.AddPoint(151, .3);
opacitytransfer.AddPoint(255, 1);
 
vtkPiecewiseFunction Gradienttransfer = new vtkPiecewiseFunction();
Gradienttransfer.AddPoint(0, .2);
Gradienttransfer.AddPoint(10, .2);
Gradienttransfer.AddPoint(25, 1);
 
vtkColorTransferFunction colorTransferFunction = new vtkColorTransferFunction();//control colors of voxels.
colorTransferFunction.AddHSVPoint(0, .67, .07, 1);
colorTransferFunction.AddHSVPoint(94, .67, .07, 1);
colorTransferFunction.AddHSVPoint(139, 0, 0, 0);
colorTransferFunction.AddHSVPoint(160, .28, .047, 1);
colorTransferFunction.AddHSVPoint(254, .38, .013, 1);
vtkVolumeProperty volumeproperty = new vtkVolumeProperty();
volumeproperty.SetColor(colorTransferFunction);
volumeproperty.SetScalarOpacity(opacitytransfer);
volumeproperty.SetGradientOpacity(Gradienttransfer);
volumeproperty.ShadeOn();
volumeproperty.SetDiffuse(2.0);
volumeproperty.SetAmbient(0.1);
volumeproperty.SetShade(1);
volumeproperty.SetSpecular(1.0);
volumeproperty.SetSpecularPower(70.0);
volumeproperty.SetInterpolationTypeToLinear();
vtkVolumeRayCastMapper volumemapper = new vtkVolumeRayCastMapper();
vtkVolumeRayCastCompositeFunction vray = new vtkVolumeRayCastCompositeFunction();
volumemapper.SetVolumeRayCastFunction(vray);
volumemapper.SetInputConnection(smooth.GetOutputPort());
vtkVolume volume = new vtkVolume();
volume.SetProperty(volumeproperty);
volume.SetMapper(volumemapper);
volumeproperty.SetInterpolationTypeToLinear();
vtkCamera acamera = new vtkCamera();
acamera.SetViewUp(0, 0, -1);
acamera.SetPosition(0, 1, 0);
acamera.SetFocalPoint(0, 0, 0);
acamera.ComputeViewPlaneNormal();
acamera.UpdateViewport(Renderer);
Renderer.AddActor(volume);
Renderer.SetActiveCamera(acamera);
Renderer.ResetCamera();
Renderer.SetBackground(0, 0, 0);
renderWindowControl1.Refresh(); 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110314/1214bdda/attachment.htm>


More information about the vtkusers mailing list