[vtkusers] rendering a series of BMP images - revisited

Darshan Pai darshanpai at gmail.com
Mon Nov 29 13:50:11 EST 2010


You probably need to set the range of the files

On Mon, Nov 29, 2010 at 11:36 AM, Prathamesh Kulkarni <
prathameshmkulkarni at gmail.com> wrote:

>
> 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()
>
> _______________________________________________
> 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/20101129/67ca58f9/attachment.htm>


More information about the vtkusers mailing list