[SciPy-user] marching cubes / isosurface in scipy?

Gennan Chen gnchen at cortechs.net
Fri Apr 28 11:16:31 CDT 2006


Thanks! I probably need to dig into VTK more

Gen


On Apr 28, 2006, at 8:39 AM, John Hunter wrote:

>>>>>> "Gennan" == Gennan Chen <gnchen at cortechs.net> writes:
>
>     Gennan> Hi!  Is there a algorithm like machine cubes or isosurface
>     Gennan> in scipy? If not, is anyone working on this type of
>     Gennan> algorithms? Since my levelset algorithms depends on that,
>     Gennan> I might need to DIY if no one is working on that.
>
> VTK has a marching cubes algorithm, and a python interface
>
>
> #!/usr/local/bin/python
> import os
>
> from vtk import *
> from colors import *
>
> ren = vtkRenderer()
> renWin = vtkRenderWindow()
> renWin.AddRenderer(ren)
> iren = vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> # create pipeline
> #
> v16 = vtkVolume16Reader()
> v16.SetDataDimensions(256,256)
> v16.GetOutput().SetOrigin(0.0,0.0,0.0)
> v16.SetFilePrefix(
>   os.environ['HOME'] + "/python/examples/vtk/images/r")
> v16.SetFilePattern( '%s%d.ima')
> v16.SetDataByteOrderToBigEndian()
> v16.SetImageRange(1001,1060)
> v16.SetDataSpacing(1.0,1.0,3.5)
> v16.Update()
>
> #vtkImageMarchingCubes iso
> iso = vtkMarchingCubes()
> iso.SetInput(v16.GetOutput())
> iso.SetValue(0,30)
> #120 vessles near cerebellum
> #100 cortex
> #20 face
> #iso SetStartMethod {puts "Start Marching"}
>
>
>
> isoMapper = vtkPolyDataMapper()
> isoMapper.SetInput(iso.GetOutput())
> isoMapper.ScalarVisibilityOff()
>
> isoActor = vtkActor()
> isoActor.SetMapper(isoMapper)
> isoActor.GetProperty().SetColor(antique_white)
>
> outline = vtkOutlineFilter()
> outline.SetInput(v16.GetOutput())
> outlineMapper = vtkPolyDataMapper()
> outlineMapper.SetInput(outline.GetOutput())
> outlineActor = vtkActor()
> outlineActor.SetMapper(outlineMapper)
> outlineActor.VisibilityOff()
>
> # Add the actors to the renderer, set the background and size
> #
> ren.AddActor(outlineActor)
> ren.AddActor(isoActor)
> ren.SetBackground(0.2,0.3,0.4)
> renWin.SetSize(450,450)
> ## ren.GetActiveCamera().Elevation(235)
> ## ren.GetActiveCamera().SetViewUp(0,.5,-1)
> ## ren.GetActiveCamera().Azimuth(90)
>
>
> iren.Initialize()
>
> iren.Start()
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>



More information about the SciPy-user mailing list