[vtkusers] volume color transferfunction help needed

Dženan Zukić dzenanz at gmail.com
Wed Mar 16 09:56:35 EDT 2011


volumeproperty.SetSpecularPower(70.0); //WTF? Specular power 70? Try
removing this line (meaning you will use the default). I suspect this is the
reason.

HTH

2011/3/14 Sarah Saeed <sosca7 at hotmail.com>

>
> *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();
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110316/60b9e23c/attachment.htm>


More information about the vtkusers mailing list