[vtkusers] Volume rendering not visible (vtkVolumeTextureMapper3D)

Bryn Lloyd lloyd at itis.ethz.ch
Mon Nov 7 11:35:55 EST 2011


Hi Sean,

 

Thanks for the reply. Did you see that I set all opacity values to 1.0, i.e.
there should be no transparent colors at all.

 

I am using Python in the example I sent. Unfortunately, I cannot help with
Activiz.NET.

 

Bryn

 

 

 

From: Sean Larkin [mailto:sean.larkin at lickenbrocktech.com] 
Sent: Monday, November 07, 2011 4:27 PM
To: 'Bryn Lloyd'
Cc: vtkusers at vtk.org
Subject: RE: [vtkusers] Volume rendering not visible
(vtkVolumeTextureMapper3D)

 

I've seen this phenomenon as well.  It might have something to do with the
opacity.  When I see this it's almost like the texture mapper is clipping
the intensity values, so that values below "x" are set to zero.  I also seem
to remember that the texture mapper has few bits of precision than
vtkVolumeRayCastMapper, i.e. only 16, rather than 32 bits.  I've adjusted
the contrast through a lookup table and adjusted the opacity when this
problem occurs, which yields a visible still image.  But when I do this I
notice that the number of gray levels in the image is small, so the image
has a lot of flat regions where it should not.  Has anyone else seen this?

 

Bryn, it looks like you're using Activiz.NET.  Is this correct?  If so,
where did you get the v5.8.0 build?

 

Sean

 

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of Bryn Lloyd
Sent: Monday, November 07, 2011 4:08 AM
To: 'vtk'
Subject: [vtkusers] Volume rendering not visible (vtkVolumeTextureMapper3D)

 

Hi

 

I am trying to figure out why for a specific dataset the volume rendering is
not visible UNLESS I am interacting with the window.

In other words, the still render is not visible. For other example datasets
(head from VTK_DATA), the still render is visible.

 

I am using the vtkVolumeTextureMapper3D (from vtk 5.8.0). The same thing
happens on OSX and Win7 installations with different hardware.

 

 

Additional information:

-          vtkGPUVolumeRayCastMapper works fine for the dataset

-          For whatever reason, if use the vtkSmartVolumeMapper, the still
render is visible even if I set the render mode to texture. 

-          The image data is 64x64x64, unsigned char, scaled to fit in
0-255.

 

Thanks for any ideas what might be going wrong. Below is the script I am
using to visualize the data.

 

Thanks,

Bryn

 

 

 

reader = vtk.vtkDataSetReader()

reader.SetFileName("C:/Temp/debug_imagedata.vtk")

reader.Update()

 

input = reader.GetStructuredPointsOutput()

 

bounds = [0,0,0,0,0,0]

input.GetBounds(bounds)

 

resample = vtk.vtkImageResample()

resample.SetInputConnection(reader.GetOutputPort())

resample.SetAxisOutputSpacing(0, (bounds[1]-bounds[0])/63.0)

resample.SetAxisOutputSpacing(1, (bounds[3]-bounds[2])/63.0)

resample.SetAxisOutputSpacing(2, (bounds[5]-bounds[4])/63.0)

resample.Update()

 

dims = [0,0,0]

resample.GetOutput().GetDimensions(dims)

print "Dimensions: ",dims

 

srange = [0,0]

resample.GetOutput().GetPointData().GetScalars().GetRange(srange)

print "Scalar range: ", srange

 

 

scale = vtk.vtkImageShiftScale()

scale.SetInputConnection(resample.GetOutputPort())

scale.SetShift(-srange[0])

scale.SetScale(255.0/(srange[1]-srange[0]))

scale.ClampOverflowOn()

scale.SetOutputScalarTypeToUnsignedChar()

scale.Update()

 

volumeMapper = vtk.vtkVolumeTextureMapper3D()

volumeMapper.SetInputConnection(scale.GetOutputPort())

 

volumeColor = vtk.vtkColorTransferFunction()

volumeColor.RemoveAllPoints()

volumeColor.AddRGBPoint(0.00, 0.0,0.0,1.0)

volumeColor.AddRGBPoint(100, 1.0,1.0,0.0)

volumeColor.AddRGBPoint(255, 1.0,0.0,0.0)

                                

volumeScalarOpacity = vtk.vtkPiecewiseFunction()

volumeScalarOpacity.RemoveAllPoints()

volumeScalarOpacity.AddPoint(  0, 1.0)

volumeScalarOpacity.AddPoint( 50, 1.0)

volumeScalarOpacity.AddPoint(150, 1.0)

volumeScalarOpacity.AddPoint(200, 1.0)

volumeScalarOpacity.AddPoint(255, 1.0)

 

volumeProperty = vtk.vtkVolumeProperty()

volumeProperty.SetColor(volumeColor)

volumeProperty.SetScalarOpacity(volumeScalarOpacity)

volumeProperty.SetInterpolationTypeToLinear()

volumeProperty.ShadeOn()

volumeProperty.SetAmbient(0.6)

volumeProperty.SetDiffuse(0.6)

volumeProperty.SetSpecular(0.5)

 

volume = vtk.vtkVolume()

volume.SetMapper(volumeMapper)

volume.SetProperty(volumeProperty)

 

 

#-----------------------------------------------------

# Create the standard renderer, render window and interactor

ren = vtk.vtkRenderer()

renWin = vtk.vtkRenderWindow()

renWin.AddRenderer(ren)

iren = vtk.vtkRenderWindowInteractor()

iren.SetRenderWindow(renWin)

 

ren.SetBackground(0.5,0.5,0.5)

ren.AddVolume(volume)

 

 

renWin.Render()

 

def CheckAbort(obj, event):

                if obj.GetEventPending() != 0:

                                obj.SetAbortRender(1)

  

renWin.AddObserver("AbortCheckEvent", CheckAbort)

iren.Initialize()

renWin.Render()

iren.Start()

 

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111107/fbed0047/attachment.htm>


More information about the vtkusers mailing list