<div dir="ltr"><div><br></div><div>Hello,</div><div><br></div><div>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. </div><div><br></div>
<div>Please point me out to where I am doing a mistake. My code is attached below.</div><div><br></div><div><br></div><div>#................................................................................................#</div>
<div><br></div><div>import vtk</div><div>from vtk import *</div><div><br></div><div>bmp_reader = vtk.vtkBMPReader()</div><div><br></div><div>bmp_reader.SetFilePrefix('../sampleData/sample_')</div><div>bmp_reader.SetFilePattern('%s%d.bmp')</div>
<div><br></div><div>#print bmp_reader</div><div><br></div><div>height = 512</div><div>width = 496</div><div>depth = 5</div><div><br></div><div>#this is default behaviour anyways..</div><div>bmp_reader.SetFileNameSliceOffset(1)</div>
<div>bmp_reader.SetFileNameSliceSpacing(1)</div><div><br></div><div>#bmp_reader.SetNumberOfScalarComponents(3)</div><div>bmp_reader.SetDataSpacing(1, 1, 1)</div><div>bmp_reader.SetDataOrigin(0, 0, 0)</div><div>bmp_reader.SetDataExtent(0, width-1, 0, height-1, 0, depth-1)</div>
<div>bmp_reader.SetDataScalarTypeToUnsignedChar()</div><div><br></div><div>alpha_channel_function = vtk.vtkPiecewiseFunction()</div><div>alpha_channel_function.AddPoint(20, 0.1)</div><div>alpha_channel_function.AddPoint(100, 1.0)</div>
<div><br></div><div>volume_property = vtk.vtkVolumeProperty()</div><div>volume_property.SetScalarOpacity(alpha_channel_function)</div><div><br></div><div>composite_function = vtk.vtkVolumeRayCastCompositeFunction()</div><div>
#volume_mapper = vtk.vtkVolumeRayCastMapper()</div><div>volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()</div><div><br></div><div>#volume_mapper.SetVolumeRayCastFunction(composite_function)</div><div>volume_mapper.SetInput(bmp_reader.GetOutput())</div>
<div><br></div><div>volume = vtk.vtkVolume()</div><div>volume.SetMapper(volume_mapper)</div><div>volume.SetProperty(volume_property)</div><div><br></div><div>renderer = vtk.vtkRenderer()</div><div>render_window = vtk.vtkRenderWindow()</div>
<div>render_window_interactor = vtk.vtkRenderWindowInteractor()</div><div><br></div><div>render_window.AddRenderer(renderer)</div><div>render_window_interactor.SetRenderWindow(render_window)</div><div><br></div><div>renderer.AddVolume(volume)</div>
<div>renderer.SetBackground(1, 1, 1)</div><div>render_window.SetSize(500, 500)</div><div><br></div><div>render_window_interactor.Initialize()</div><div>render_window.Render()</div><div>render_window_interactor.Start()</div>
</div>