[vtkusers] stupid question re: volSimple.py

Robert Belleman robbel at science.uva.nl
Wed Aug 8 09:13:10 EDT 2001


Maneesh,

On Tue, Aug 07, 2001 at 03:54:32PM -0400, Maneesh Yadav wrote:
> Hi all, I'm having a bit o' trouble visualizing my data...
> I stripped the header of the stack as was suggested earlier on the list
> and I should be left with the raw data (it's the right size)...
> to load the data I do this:

I have converted your script to Tcl to verify your code.

> reader=vtkImageReader()
> reader.SetFileName("dataset.raw")
> reader.SetDataExtent(0,255,0,255,0,249)
> reader.SetFileDimensionality(3)
> reader.SetHeaderSize(0)
> reader.SetDataByteOrderToLittleEndian()
> reader.SetDataOrigin(0,0,0)
> reader.SetDataScalarTypeToUnsignedChar()
> reader.SetDataSpacing(1.0,1.0,1.0)
> reader.GetOutput().ReleaseDataFlagOn()

This is fine. Note that "reader.SetDataByteOrderToLittleEndian" isn't
really needed since the data is 1 byte per pixel (byte order is important
of the data consists of more than one byte per voxel). The values you set
for HeaderSize, DataOrigin and DataSpacing are the same by default, I
think, but it can't harm to set them explicitly.

> opacityTransferFunction = vtkPiecewiseFunction()
> opacityTransferFunction.AddPoint(20,0.0)
> opacityTransferFunction.AddPoint(255,0.2)

You may want to change this a little. This will result in opaque voxels
for values between 0 and 20 which will obscure the "interesting" bits.

Try

opacityTransferFunction.AddPoint(0, 0.8)
opacityTransferFunction.AddPoint(255, 0.0)

> colorTransferFunction = vtkColorTransferFunction()
> colorTransferFunction.AddRedPoint(0.0,0.0)
> colorTransferFunction.AddRedPoint(64.0,1.0)
> colorTransferFunction.AddRedPoint(128.0,0.0)
> colorTransferFunction.AddRedPoint(255.0,0.0)
[... etc.]

You are probably using an old version of Vtk; my version warns me that
Add(Red|Green|Blue)Point is deprecated and I should use AddRGBPoint
instead.

Try

colorTransferFunction.AddRGBPoint(0,   0.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(64,  1.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(128, 0.0, 1.0, 0.0)
colorTransferFunction.AddRGBPoint(192, 0.0, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(255, 0.0, 0.0, 0.2)

> The program starts a window comes then dissappears (no coredump)...

Ah... Maybe you should try a newer version of Vtk, because everything
else looks fine to me.

Good luck,
-- Rob

-- 
[] Robert Belleman         X  Section Computational Science            []
[] robbel at science.uva.nl  |X| University of Amsterdam, the Netherlands []
[] tel: (+31) 20 525 7510  X  http://www.science.uva.nl/~robbel/       []




More information about the vtkusers mailing list