Пример #1
0
    def test_sitk2vtk(self):
        print("Testing sitk2vtk")
        dims = [102, 102, 102]
        img = sitk.GaussianSource(sitk.sitkUInt8, dims)

        if platform.system() == "Windows":
            invol = vtk.vtkImageData()
            invol.SetDimensions(10, 10, 10)
            vol = sitk2vtk.sitk2vtk(img, invol, True)
            print("Accessing VTK image")
            print(invol.GetScalarComponentAsFloat(5, 5, 5, 0))
        else:
            vol = sitk2vtk.sitk2vtk(img, None, True)
            self.assertTupleEqual(vol.GetDimensions(), tuple(dims))
            print("Accessing VTK image")
            val = vol.GetScalarComponentAsFloat(5, 5, 5, 0)
            print(val)
            self.assertAlmostEqual(val, 3.0)
Пример #2
0
    print("")

#vtkname =  tempDir+"/vol.vtk"
#sitk.WriteImage( img, vtkname )

import platform
from utils import sitk2vtk
import vtk
vtkimg = None

if platform.system() is "Windows":
    # hacky work-around to avoid a crash on Windows
    vtkimg = vtk.vtkImageData()
    vtkimg.SetDimensions(10, 10, 10)
    vtkimg.AllocateScalars(vtk.VTK_CHAR, 1)
    sitk2vtk.sitk2vtk(img, vtkimg, False)
else:
    vtkimg = sitk2vtk.sitk2vtk(img)

img = None
gc.collect()

import traceback
import vtk

if debug:
    print("\nVTK version: ", vtk.vtkVersion.GetVTKVersion())
    print("VTK: ", vtk, "\n")

from utils import vtkutils
Пример #3
0
gc.collect()

if args.verbose:
    print("\nImage for isocontouring")
    print(img.GetSize())
    print(img.GetPixelIDTypeAsString())
    print(img.GetSpacing())
    print(img.GetOrigin())
    if args.verbose > 1:
        print(img)
    print("")

# vtkname =  tempDir+"/vol.vtk"
# sitk.WriteImage( img, vtkname )

vtkimg = sitk2vtk.sitk2vtk(img)

img = None
gc.collect()

if args.debug:
    print("\nVTK version: ", vtk.vtkVersion.GetVTKVersion())
    print("VTK: ", vtk, "\n")

if args.debug:
    print("Extracting surface")
mesh = vtkutils.extractSurface(vtkimg, isovalue)
vtkimg = None
gc.collect()
if args.debug:
    print("Cleaning mesh")