[vtkusers] Problem with volume rendering and 2 independent components
Lisa Avila
lisa.avila at kitware.com
Wed Jun 22 09:47:28 EDT 2005
Hi Jef,
I am not sure how loading the data into VolView is producing "the expected
results" - VolView (and therefore the mappers in VTK) does not support
mapping the first component to value and the second to hue. What you can do
is map the first component to hue (or any hsv or rgb colormap) and the
second to opacity. This can be done with the
vtkFixedPointVolumeRayCastMapper and the vtkVolumeTextureMapper3D. The
other volume mappers only support one component data.
Lisa
At 03:17 AM 6/22/2005, Jef Driesen wrote:
>I have a volume dataset (64x64x30) with 2 independent components. The
>first component is the average value and the second the standard
>deviation of a dataset, both scaled to unsigned shorts. I want to render
>a volume from this dataset. The first component should be represented by
>the 'value' in the HSV color space and the second component by the
>'hue'. I have added my code (in java) below. But the result looks like
>garbage. When I render each component separatly (using the same transfer
>functions) everything looks like it should be. Loading the dataset in
>volview 2.0 produces the expected result. What am I doing wrong?
>
> public static void render_volume_uint16() {
> double[] range = {0.0, 255.0 * 255.0};
>
> // Create the image reader and
> // extract the volume of interest (VOI)
> vtkImageReader reader = new vtkImageReader();
> reader.SetFileName("volume-uint16.img");
> reader.SetDataExtent(0,63,0,63,0,29);
> reader.SetFileDimensionality(3);
> reader.SetDataSpacing(3,3,3);
> reader.SetDataByteOrderToLittleEndian();
> reader.SetDataScalarTypeToUnsignedShort();
> reader.SetNumberOfScalarComponents(2);
>
> // Transfer functions
> vtkPiecewiseFunction transfer_linear = new vtkPiecewiseFunction();
> transfer_linear.AddPoint(range[0], 0.0); // transparent
> transfer_linear.AddPoint(range[1], 1.0); // opaque
>
> vtkColorTransferFunction transfer_grayscale = new
>vtkColorTransferFunction();
> transfer_grayscale.AddHSVPoint(range[0], 0.0, 0.0, 0.0); //
>white
> transfer_grayscale.AddHSVPoint(range[1], 0.0, 0.0, 1.0); //
>black
>
> vtkColorTransferFunction transfer_hue = new
>vtkColorTransferFunction();
> transfer_hue.AddHSVPoint(range[0], 0.66, 1.0, 1.0); // blue
> transfer_hue.AddHSVPoint(0.5 * (range[1] - range[0]), 0.33,
>1.0, 1.0); // green
> transfer_hue.AddHSVPoint(range[1], 0.00, 1.0, 1.0); // red
>
> // Maximum intensity projection ray caster
> vtkVolumeRayCastCompositeFunction composite = new
>vtkVolumeRayCastCompositeFunction();
> vtkVolumeRayCastMIPFunction mip = new vtkVolumeRayCastMIPFunction();
> vtkVolumeRayCastMapper mapper = new vtkVolumeRayCastMapper();
> mapper.SetInput(reader.GetOutput());
> mapper.SetVolumeRayCastFunction(mip);
>
> // Volume properties
> vtkVolumeProperty prop = new vtkVolumeProperty();
> prop.IndependentComponentsOn();
> prop.SetInterpolationTypeToLinear();
> prop.SetScalarOpacity(0,transfer_linear);
> prop.SetColor(0,transfer_grayscale);
> prop.SetComponentWeight(0,1.0);
> prop.SetScalarOpacity(1,transfer_linear);
> prop.SetColor(1,transfer_hue);
> prop.SetComponentWeight(1,1.0);
>
> // Volume
> vtkVolume volume = new vtkVolume();
> volume.SetMapper(mapper);
> volume.SetProperty(prop);
>
> // Renderer
> vtkRenderer ren = new vtkRenderer();
> ren.AddVolume(volume);
> //ren.SetBackground(1,1,1);
>
> // Render window
> vtkRenderWindow win = new vtkRenderWindow();
> win.AddRenderer(ren);
>
> // Render window interactor
> vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
> iren.SetRenderWindow(win);
> iren.Initialize();
> iren.Start();
> }
>
>_________________________________________________________________
>Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be
>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages on-topic.
>Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list