[vtkusers] rendering a series of BMP images - revisited

Prathamesh Kulkarni prathameshmkulkarni at gmail.com
Mon Nov 29 11:36:04 EST 2010


Hello,

I am trying to render a series of BMP images as a volume using Ray Casting
in vtk. However, what I see is only a single slice of image.

Please point me out to where I am doing a mistake. My code is attached
below.


#................................................................................................#

import vtk
from vtk import *

bmp_reader = vtk.vtkBMPReader()

bmp_reader.SetFilePrefix('../sampleData/sample_')
bmp_reader.SetFilePattern('%s%d.bmp')

#print bmp_reader

height = 512
width = 496
depth = 5

#this is default behaviour anyways..
bmp_reader.SetFileNameSliceOffset(1)
bmp_reader.SetFileNameSliceSpacing(1)

#bmp_reader.SetNumberOfScalarComponents(3)
bmp_reader.SetDataSpacing(1, 1, 1)
bmp_reader.SetDataOrigin(0, 0, 0)
bmp_reader.SetDataExtent(0, width-1, 0, height-1, 0, depth-1)
bmp_reader.SetDataScalarTypeToUnsignedChar()

alpha_channel_function = vtk.vtkPiecewiseFunction()
alpha_channel_function.AddPoint(20, 0.1)
alpha_channel_function.AddPoint(100, 1.0)

volume_property = vtk.vtkVolumeProperty()
volume_property.SetScalarOpacity(alpha_channel_function)

composite_function = vtk.vtkVolumeRayCastCompositeFunction()
#volume_mapper = vtk.vtkVolumeRayCastMapper()
volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()

#volume_mapper.SetVolumeRayCastFunction(composite_function)
volume_mapper.SetInput(bmp_reader.GetOutput())

volume = vtk.vtkVolume()
volume.SetMapper(volume_mapper)
volume.SetProperty(volume_property)

renderer = vtk.vtkRenderer()
render_window = vtk.vtkRenderWindow()
render_window_interactor = vtk.vtkRenderWindowInteractor()

render_window.AddRenderer(renderer)
render_window_interactor.SetRenderWindow(render_window)

renderer.AddVolume(volume)
renderer.SetBackground(1, 1, 1)
render_window.SetSize(500, 500)

render_window_interactor.Initialize()
render_window.Render()
render_window_interactor.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101129/b6ba7389/attachment.htm>


More information about the vtkusers mailing list