本文整理汇总了Python中vtk.vtkVolume16Reader函数的典型用法代码示例。如果您正苦于以下问题:Python vtkVolume16Reader函数的具体用法?Python vtkVolume16Reader怎么用?Python vtkVolume16Reader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkVolume16Reader函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkVolume16Reader(), 'Reading vtkVolume16.',
(), ('vtkVolume16',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkVolume16Reader.py
示例2: testBug
def testBug(self):
# Uncomment the next line if you want to run this via
# `gdb python`.
#raw_input('Hit Ctrl-C')
# Load some data.
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64, 64)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix(os.path.join(Testing.VTK_DATA_ROOT,
"Data", "headsq", "quarter"))
v16.SetImageRange(1, 93)
v16.SetDataSpacing(3.2, 3.2, 1.5)
v16.Update()
xMin, xMax, yMin, yMax, zMin, zMax = v16.GetOutput().GetWholeExtent()
img_data = v16.GetOutput()
# **************************************************
# Look here for wierdness.
# Lets create this data using the data from the reader.
my_img_data = vtk.vtkImageData()
my_img_data.SetDimensions(img_data.GetDimensions())
my_img_data.SetWholeExtent(img_data.GetWholeExtent())
my_img_data.SetExtent(img_data.GetExtent())
my_img_data.SetUpdateExtent(img_data.GetUpdateExtent())
my_img_data.SetSpacing(img_data.GetSpacing())
my_img_data.SetOrigin(img_data.GetOrigin())
my_img_data.SetScalarType(img_data.GetScalarType())
my_img_data.GetPointData().SetScalars(img_data.GetPointData().GetScalars())
my_img_data.Update()
# hang on to original image data.
orig_img_data = img_data
# hijack img_data with our own. If you comment this out everything is
# fine.
img_data = my_img_data
# **************************************************
spacing = img_data.GetSpacing()
sx, sy, sz = spacing
origin = img_data.GetOrigin()
ox, oy, oz = origin
# An outline is shown for context.
outline = vtk.vtkOutlineFilter()
outline.SetInput(img_data)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# The shared picker enables us to use 3 planes at one time
# and gets the picking order right
picker = vtk.vtkCellPicker()
picker.SetTolerance(0.005)
# The 3 image plane widgets are used to probe the dataset.
planeWidgetX = vtk.vtkImagePlaneWidget()
planeWidgetX.DisplayTextOn()
planeWidgetX.SetInput(img_data)
planeWidgetX.SetPlaneOrientationToXAxes()
planeWidgetX.SetSliceIndex(32)
planeWidgetX.SetPicker(picker)
planeWidgetX.SetKeyPressActivationValue("x")
prop1 = planeWidgetX.GetPlaneProperty()
prop1.SetColor(1, 0, 0)
planeWidgetY = vtk.vtkImagePlaneWidget()
planeWidgetY.DisplayTextOn()
planeWidgetY.SetInput(img_data)
planeWidgetY.SetPlaneOrientationToYAxes()
planeWidgetY.SetSliceIndex(32)
planeWidgetY.SetPicker(picker)
planeWidgetY.SetKeyPressActivationValue("y")
prop2 = planeWidgetY.GetPlaneProperty()
prop2.SetColor(1, 1, 0)
planeWidgetY.SetLookupTable(planeWidgetX.GetLookupTable())
# for the z-slice, turn off texture interpolation:
# interpolation is now nearest neighbour, to demonstrate
# cross-hair cursor snapping to pixel centers
planeWidgetZ = vtk.vtkImagePlaneWidget()
planeWidgetZ.DisplayTextOn()
planeWidgetZ.SetInput(img_data)
planeWidgetZ.SetPlaneOrientationToZAxes()
planeWidgetZ.SetSliceIndex(46)
planeWidgetZ.SetPicker(picker)
planeWidgetZ.SetKeyPressActivationValue("z")
prop3 = planeWidgetZ.GetPlaneProperty()
prop3.SetColor(0, 0, 1)
planeWidgetZ.SetLookupTable(planeWidgetX.GetLookupTable())
# Create the RenderWindow and Renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
#.........这里部分代码省略.........
开发者ID:unidevop,项目名称:sjtu-project-pipe,代码行数:101,代码来源:TestImagePlaneWidget.py
示例3: slices
# Create the renderer, the render window, and the interactor. The renderer
# draws into the render window, the interactor enables mouse- and
# keyboard-based interaction with the scene.
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# The following reader is used to read a series of 2D slices (images)
# that compose the volume. The slice dimensions are set, and the
# pixel spacing. The data Endianness must also be specified. The reader
# usese the FilePrefix in combination with the slice number to construct
# filenames using the format FilePrefix.%d. (In this case the FilePrefix
# is the root name of the file: quarter.)
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64, 64)
v16.SetImageRange(1, 93)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
v16.SetDataSpacing(3.2, 3.2, 1.5)
# The volume will be displayed by ray-cast alpha compositing.
# A ray-cast mapper is needed to do the ray-casting, and a
# compositing function is needed to do the compositing along the ray.
rayCastFunction = vtk.vtkVolumeRayCastCompositeFunction()
volumeMapper = vtk.vtkVolumeRayCastMapper()
volumeMapper.SetInputConnection(v16.GetOutputPort())
volumeMapper.SetVolumeRayCastFunction(rayCastFunction)
开发者ID:behollis,项目名称:vtk-gsoc,代码行数:30,代码来源:Medical4.py
示例4: testImagePlaneWidget
def testImagePlaneWidget(self):
"A more rigorous test using the image plane widget."
# This test is largely copied from
# Widgets/Python/TestImagePlaneWidget.py
# Load some data.
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64, 64)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix(os.path.join(VTK_DATA_ROOT, "Data", "headsq", "quarter"))
v16.SetImageRange(1, 93)
v16.SetDataSpacing(3.2, 3.2, 1.5)
v16.Update()
xMin, xMax, yMin, yMax, zMin, zMax = v16.GetExecutive().GetWholeExtent(v16.GetOutputInformation(0))
img_data = v16.GetOutput()
spacing = img_data.GetSpacing()
sx, sy, sz = spacing
origin = img_data.GetOrigin()
ox, oy, oz = origin
# An outline is shown for context.
outline = vtk.vtkOutlineFilter()
outline.SetInputData(img_data)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# The shared picker enables us to use 3 planes at one time
# and gets the picking order right
picker = vtk.vtkCellPicker()
picker.SetTolerance(0.005)
# The 3 image plane widgets are used to probe the dataset.
planeWidgetX = vtk.vtkImagePlaneWidget()
planeWidgetX.DisplayTextOn()
planeWidgetX.SetInputData(img_data)
planeWidgetX.SetPlaneOrientationToXAxes()
planeWidgetX.SetSliceIndex(32)
planeWidgetX.SetPicker(picker)
planeWidgetX.SetKeyPressActivationValue("x")
prop1 = planeWidgetX.GetPlaneProperty()
prop1.SetColor(1, 0, 0)
planeWidgetY = vtk.vtkImagePlaneWidget()
planeWidgetY.DisplayTextOn()
planeWidgetY.SetInputData(img_data)
planeWidgetY.SetPlaneOrientationToYAxes()
planeWidgetY.SetSliceIndex(32)
planeWidgetY.SetPicker(picker)
planeWidgetY.SetKeyPressActivationValue("y")
prop2 = planeWidgetY.GetPlaneProperty()
prop2.SetColor(1, 1, 0)
planeWidgetY.SetLookupTable(planeWidgetX.GetLookupTable())
# for the z-slice, turn off texture interpolation:
# interpolation is now nearest neighbour, to demonstrate
# cross-hair cursor snapping to pixel centers
planeWidgetZ = vtk.vtkImagePlaneWidget()
planeWidgetZ.DisplayTextOn()
planeWidgetZ.SetInputData(img_data)
planeWidgetZ.SetPlaneOrientationToZAxes()
planeWidgetZ.SetSliceIndex(46)
planeWidgetZ.SetPicker(picker)
planeWidgetZ.SetKeyPressActivationValue("z")
prop3 = planeWidgetZ.GetPlaneProperty()
prop3.SetColor(0, 0, 1)
planeWidgetZ.SetLookupTable(planeWidgetX.GetLookupTable())
# Now create another actor with an opacity < 1 and with some
# scalars.
p = vtk.vtkPolyData()
pts = vtk.vtkPoints()
pts.InsertNextPoint((0, 0, 0))
sc = vtk.vtkFloatArray()
sc.InsertNextValue(1.0)
p.SetPoints(pts)
p.GetPointData().SetScalars(sc)
m = vtk.vtkPolyDataMapper()
m.SetInputData(p)
# Share the lookup table of the widgets.
m.SetLookupTable(planeWidgetX.GetLookupTable())
m.UseLookupTableScalarRangeOn()
dummyActor = vtk.vtkActor()
dummyActor.SetMapper(m)
dummyActor.GetProperty().SetOpacity(0.0)
# Create the RenderWindow and Renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren)
# Add the dummy actor.
ren.AddActor(dummyActor)
# Add the outline actor to the renderer, set the background
#.........这里部分代码省略.........
开发者ID:RCBiczok,项目名称:VTK,代码行数:101,代码来源:TestMapperLUT.py
示例5: testSkinOrder
def testSkinOrder(self):
# Create the RenderWindow, Renderer and Interactor
#
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
RESOLUTION = 64
START_SLICE = 50
END_SLICE = 60
PIXEL_SIZE = 3.2
centerX = RESOLUTION / 2
centerY = RESOLUTION / 2
centerZ = (END_SLICE - START_SLICE) / 2
endX = RESOLUTION - 1
endY = RESOLUTION - 1
endZ = END_SLICE - 1
origin = (RESOLUTION / 2.0) * PIXEL_SIZE * -1.0
math = vtk.vtkMath()
orders = ["ap", "pa", "si", "iss", "lr", "rl"]
sliceOrder = SliceOrder.SliceOrder()
reader = list()
iso = list()
mapper = list()
actor = list()
skinColors = [
[0.875950, 0.598302, 0.656878],
[0.641134, 0.536594, 0.537889],
[0.804079, 0.650506, 0.558249],
[0.992896, 0.603716, 0.660385],
[0.589101, 0.513448, 0.523095],
[0.650247, 0.700527, 0.752458],
]
for idx, order in enumerate(orders):
reader.append(vtk.vtkVolume16Reader())
reader[idx].SetDataDimensions(RESOLUTION, RESOLUTION)
reader[idx].SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
reader[idx].SetDataSpacing(PIXEL_SIZE, PIXEL_SIZE, 1.5)
reader[idx].SetDataOrigin(origin, origin, 1.5)
reader[idx].SetImageRange(START_SLICE, END_SLICE)
if order == "ap":
reader[idx].SetTransform(sliceOrder.ap)
elif order == "pa":
reader[idx].SetTransform(sliceOrder.pa)
elif order == "si":
reader[idx].SetTransform(sliceOrder.si)
elif order == "iss":
reader[idx].SetTransform(sliceOrder.iss)
elif order == "lr":
reader[idx].SetTransform(sliceOrder.lr)
elif order == "rl":
reader[idx].SetTransform(sliceOrder.rl)
else:
s = "No such transform exists."
raise Exception(s)
reader[idx].SetHeaderSize(0)
reader[idx].SetDataMask(0x7FFF)
reader[idx].SetDataByteOrderToLittleEndian()
reader[idx].GetExecutive().SetReleaseDataFlag(0, 1)
iso.append(vtk.vtkContourFilter())
iso[idx].SetInputConnection(reader[idx].GetOutputPort())
iso[idx].SetValue(0, 550.5)
iso[idx].ComputeScalarsOff()
iso[idx].ReleaseDataFlagOn()
mapper.append(vtk.vtkPolyDataMapper())
mapper[idx].SetInputConnection(iso[idx].GetOutputPort())
mapper[idx].ImmediateModeRenderingOn()
actor.append(vtk.vtkActor())
actor[idx].SetMapper(mapper[idx])
# r = math.Random(.5, 1)
# g = math.Random(.5, 1)
# b = math.Random(.5, 1)
# print r, g, b
actor[idx].GetProperty().SetDiffuseColor(
# math.Random(.5, 1), math.Random(.5, 1), math.Random(.5, 1))
# r, g, b)
skinColors[idx]
)
ren.AddActor(actor[idx])
renWin.SetSize(300, 300)
ren.ResetCamera()
ren.GetActiveCamera().Azimuth(210)
ren.GetActiveCamera().Elevation(30)
ren.GetActiveCamera().Dolly(1.2)
ren.ResetCameraClippingRange()
ren.SetBackground(0.8, 0.8, 0.8)
# render and interact with data
#.........这里部分代码省略.........
开发者ID:jlec,项目名称:VTK,代码行数:101,代码来源:skinOrder.py
示例6: __init__
def __init__(self):
# Create the renderer, the render window, and the interactor. The
# renderer draws into the render window, the interactor enables mouse-
# and keyboard-based interaction with the scene.
self.ren = vtk.vtkRenderer()
self.renwin = vtk.vtkRenderWindow()
self.renwin.AddRenderer(self.ren)
self.iren = vtk.vtkRenderWindowInteractor()
self.iren.SetRenderWindow(self.renwin)
# Create text mappers and 2d actors to display finger position.
self.fingerMarker1 = Marker("(1)")
self.fingerMarker2 = Marker("(2)")
self.fingerMarker3 = Marker("(3)")
# The following reader is used to read a series of 2D slices (images)
# that compose the volume. The slice dimensions are set, and the
# pixel spacing. The data Endianness must also be specified. The reader
# usese the FilePrefix in combination with the slice number to construct
# filenames using the format FilePrefix.%d. (In this case the FilePrefix
# is the root name of the file: quarter.)
self.v16 = vtk.vtkVolume16Reader()
self.v16.SetDataDimensions(64, 64)
self.v16.SetDataByteOrderToLittleEndian()
self.v16.SetFilePrefix("/Users/eddie/Programming/Python/python-vtk-tuio/headsq/Data_headsq_quarter")
self.v16.SetImageRange(1, 93)
self.v16.SetDataSpacing(3.2, 3.2, 1.5)
# An isosurface, or contour value of 500 is known to correspond to the
# skin of the patient. Once generated, a vtkPolyDataNormals filter is
# is used to create normals for smooth surface shading during rendering.
# The triangle stripper is used to create triangle strips from the
# isosurface these render much faster on may systems.
self.skinExtractor = vtk.vtkContourFilter()
self.skinExtractor.SetInputConnection(self.v16.GetOutputPort())
self.skinExtractor.SetValue(0, 500)
self.skinNormals = vtk.vtkPolyDataNormals()
self.skinNormals.SetInputConnection(self.skinExtractor.GetOutputPort())
self.skinNormals.SetFeatureAngle(60.0)
self.skinStripper = vtk.vtkStripper()
self.skinStripper.SetInputConnection(self.skinNormals.GetOutputPort())
self.skinMapper = vtk.vtkPolyDataMapper()
self.skinMapper.SetInputConnection(self.skinStripper.GetOutputPort())
self.skinMapper.ScalarVisibilityOff()
self.skin = vtk.vtkActor()
self.skin.SetMapper(self.skinMapper)
self.skin.GetProperty().SetDiffuseColor(1, .49, .25)
self.skin.GetProperty().SetSpecular(.3)
self.skin.GetProperty().SetSpecularPower(20)
# An isosurface, or contour value of 1150 is known to correspond to the
# skin of the patient. Once generated, a vtkPolyDataNormals filter is
# is used to create normals for smooth surface shading during rendering.
# The triangle stripper is used to create triangle strips from the
# isosurface these render much faster on may systems.
self.boneExtractor = vtk.vtkContourFilter()
self.boneExtractor.SetInputConnection(self.v16.GetOutputPort())
self.boneExtractor.SetValue(0, 1150)
self.boneNormals = vtk.vtkPolyDataNormals()
self.boneNormals.SetInputConnection(self.boneExtractor.GetOutputPort())
self.boneNormals.SetFeatureAngle(60.0)
self.boneStripper = vtk.vtkStripper()
self.boneStripper.SetInputConnection(self.boneNormals.GetOutputPort())
self.boneMapper = vtk.vtkPolyDataMapper()
self.boneMapper.SetInputConnection(self.boneStripper.GetOutputPort())
self.boneMapper.ScalarVisibilityOff()
self.bone = vtk.vtkActor()
self.bone.SetMapper(self.boneMapper)
self.bone.GetProperty().SetDiffuseColor(1, 1, .9412)
# An outline provides context around the data.
self.outlineData = vtk.vtkOutlineFilter()
self.outlineData.SetInputConnection(self.v16.GetOutputPort())
self.mapOutline = vtk.vtkPolyDataMapper()
self.mapOutline.SetInputConnection(self.outlineData.GetOutputPort())
self.outline = vtk.vtkActor()
self.outline.SetMapper(self.mapOutline)
self.outline.GetProperty().SetColor(0, 0, 0)
# Now we are creating three orthogonal planes passing through the
# volume. Each plane uses a different texture map and therefore has
# diferent coloration.
# Start by creatin a black/white lookup table.
self.bwLut = vtk.vtkLookupTable()
self.bwLut.SetTableRange(0, 2000)
self.bwLut.SetSaturationRange(0, 0)
self.bwLut.SetHueRange(0, 0)
self.bwLut.SetValueRange(0, 1)
self.bwLut.Build()
# Now create a lookup table that consists of the full hue circle (from
# HSV).
self.hueLut = vtk.vtkLookupTable()
self.hueLut.SetTableRange(0, 2000)
self.hueLut.SetHueRange(0, 1)
self.hueLut.SetSaturationRange(1, 1)
self.hueLut.SetValueRange(1, 1)
self.hueLut.Build()
#.........这里部分代码省略.........
开发者ID:hnieto,项目名称:python-vtk-tuio,代码行数:101,代码来源:SingleSlice.py
示例7:
#!/usr/local/bin/python
import os
import vtk
from WindowLevelInterface import WindowLevelInterface
# Create reader - you have total flexibility to specify the file
# naming pattern, the byte order, the size of the header and so on
reader = vtk.vtkVolume16Reader()
reader.SetDataDimensions(256,256)
reader.GetOutput().SetOrigin(0.0,0.0,0.0)
reader.SetFilePrefix('../data/images/r')
reader.SetFilePattern( '%s%d.ima')
reader.SetDataByteOrderToBigEndian()
reader.SetImageRange(1001,1060)
reader.SetDataSpacing(1.0,1.0,3.5)
reader.Update()
# VTK comes with a helper class to view slice data
viewer = vtk.vtkImageViewer()
viewer.SetInput(reader.GetOutput())
viewer.SetZSlice(30)
viewer.SetColorWindow(600)
viewer.SetColorLevel(270)
viewer.Render()
viewer.SetPosition(50,50)
# A helper class to set the window level, etc
WindowLevelInterface(viewer)
开发者ID:acaballero6270,项目名称:py4science,代码行数:28,代码来源:vtk_slice_viewer.py
示例8: testVolumePicker
def testVolumePicker(self):
# volume render a medical data set
# renderer and interactor
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin)
# read the volume
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64, 64)
v16.SetImageRange(1, 93)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
v16.SetDataSpacing(3.2, 3.2, 1.5)
#---------------------------------------------------------
# set up the volume rendering
volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
volumeMapper.SetInputConnection(v16.GetOutputPort())
volumeColor = vtk.vtkColorTransferFunction()
volumeColor.AddRGBPoint(0, 0.0, 0.0, 0.0)
volumeColor.AddRGBPoint(180, 0.3, 0.1, 0.2)
volumeColor.AddRGBPoint(1000, 1.0, 0.7, 0.6)
volumeColor.AddRGBPoint(2000, 1.0, 1.0, 0.9)
volumeScalarOpacity = vtk.vtkPiecewiseFunction()
volumeScalarOpacity.AddPoint(0, 0.0)
volumeScalarOpacity.AddPoint(180, 0.0)
volumeScalarOpacity.AddPoint(1000, 0.2)
volumeScalarOpacity.AddPoint(2000, 0.8)
volumeGradientOpacity = vtk.vtkPiecewiseFunction()
volumeGradientOpacity.AddPoint(0, 0.0)
volumeGradientOpacity.AddPoint(90, 0.5)
volumeGradientOpacity.AddPoint(100, 1.0)
volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(volumeColor)
volumeProperty.SetScalarOpacity(volumeScalarOpacity)
volumeProperty.SetGradientOpacity(volumeGradientOpacity)
volumeProperty.SetInterpolationTypeToLinear()
volumeProperty.ShadeOn()
volumeProperty.SetAmbient(0.6)
volumeProperty.SetDiffuse(0.6)
volumeProperty.SetSpecular(0.1)
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)
#---------------------------------------------------------
# Do the surface rendering
boneExtractor = vtk.vtkMarchingCubes()
boneExtractor.SetInputConnection(v16.GetOutputPort())
boneExtractor.SetValue(0, 1150)
boneNormals = vtk.vtkPolyDataNormals()
boneNormals.SetInputConnection(boneExtractor.GetOutputPort())
boneNormals.SetFeatureAngle(60.0)
boneStripper = vtk.vtkStripper()
boneStripper.SetInputConnection(boneNormals.GetOutputPort())
boneMapper = vtk.vtkPolyDataMapper()
boneMapper.SetInputConnection(boneStripper.GetOutputPort())
boneMapper.ScalarVisibilityOff()
boneProperty = vtk.vtkProperty()
boneProperty.SetColor(1.0, 1.0, 0.9)
bone = vtk.vtkActor()
bone.SetMapper(boneMapper)
bone.SetProperty(boneProperty)
#---------------------------------------------------------
# Create an image actor
table = vtk.vtkLookupTable()
table.SetRange(0, 2000)
table.SetRampToLinear()
table.SetValueRange(0, 1)
table.SetHueRange(0, 0)
table.SetSaturationRange(0, 0)
mapToColors = vtk.vtkImageMapToColors()
mapToColors.SetInputConnection(v16.GetOutputPort())
mapToColors.SetLookupTable(table)
imageActor = vtk.vtkImageActor()
imageActor.GetMapper().SetInputConnection(mapToColors.GetOutputPort())
imageActor.SetDisplayExtent(32, 32, 0, 63, 0, 92)
#---------------------------------------------------------
#.........这里部分代码省略.........
开发者ID:ColorVertexSampleOrganization,项目名称:VTK,代码行数:101,代码来源:VolumePicker.py
示例9: get_actors
def get_actors(args):
# The following reader is used to read a series of 2D slices (images)
# that compose the volume. The slice dimensions are set, and the
# pixel spacing. The data Endianness must also be specified. The reader
# usese the FilePrefix in combination with the slice number to construct
# filenames using the format FilePrefix.%d. (In this case the FilePrefix
# is the root name of the file: quarter.)
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64, 64)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix(args[0])
v16.SetImageRange(1, 93)
v16.SetDataSpacing(3.2, 3.2, 1.5)
# An isosurface, or contour value of 500 is known to correspond to the
# skin of the patient. Once generated, a vtkPolyDataNormals filter is
# is used to create normals for smooth surface shading during rendering.
# The triangle stripper is used to create triangle strips from the
# isosurface these render much faster on may systems.
skinExtractor = vtk.vtkContourFilter()
skinExtractor.SetInputConnection(v16.GetOutputPort())
skinExtractor.SetValue(0, 500)
skinNormals = vtk.vtkPolyDataNormals()
skinNormals.SetInputConnection(skinExtractor.GetOutputPort())
skinNormals.SetFeatureAngle(60.0)
skinStripper = vtk.vtkStripper()
skinStripper.SetInputConnection(skinNormals.GetOutputPort())
skinMapper = vtk.vtkPolyDataMapper()
skinMapper.SetInputConnection(skinStripper.GetOutputPort())
skinMapper.ScalarVisibilityOff()
skin = vtk.vtkActor()
skin.SetMapper(skinMapper)
skin.GetProperty().SetDiffuseColor(1, .49, .25)
skin.GetProperty().SetSpecular(.3)
skin.GetProperty().SetSpecularPower(20)
# An isosurface, or contour value of 1150 is known to correspond to the
# skin of the patient. Once generated, a vtkPolyDataNormals filter is
# is used to create normals for smooth surface shading during rendering.
# The triangle stripper is used to create triangle strips from the
# isosurface these render much faster on may systems.
boneExtractor = vtk.vtkContourFilter()
boneExtractor.SetInputConnection(v16.GetOutputPort())
boneExtractor.SetValue(0, 1150)
boneNormals = vtk.vtkPolyDataNormals()
boneNormals.SetInputConnection(boneExtractor.GetOutputPort())
boneNormals.SetFeatureAngle(60.0)
boneStripper = vtk.vtkStripper()
boneStripper.SetInputConnection(boneNormals.GetOutputPort())
boneMapper = vtk.vtkPolyDataMapper()
boneMapper.SetInputConnection(boneStripper.GetOutputPort())
boneMapper.ScalarVisibilityOff()
bone = vtk.vtkActor()
bone.SetMapper(boneMapper)
bone.GetProperty().SetDiffuseColor(1, 1, .9412)
# An outline provides context around the data.
outlineData = vtk.vtkOutlineFilter()
outlineData.SetInputConnection(v16.GetOutputPort())
mapOutline = vtk.vtkPolyDataMapper()
mapOutline.SetInputConnection(outlineData.GetOutputPort())
outline = vtk.vtkActor()
outline.SetMapper(mapOutline)
outline.GetProperty().SetColor(0, 0, 0)
return (outline, skin, bone)
开发者ID:piotrdomagalski,项目名称:VTKToOSG,代码行数:66,代码来源:Medical2.py
示例10: generateDemoData
def generateDemoData( self ):
VTK_DATA_ROOT = getVTKDataRoot()
if not self.dataset in demoDatasets:
print>>sys.stderr, "Unknown dataset: %s " % self.dataset
self.dataset = demoDatasets[0]
if self.dataset == 'head':
self.reader = vtk.vtkVolume16Reader()
self.reader.SetDataDimensions(64, 64)
self.reader.SetDataByteOrderToLittleEndian()
self.reader.SetFilePrefix( VTK_DATA_ROOT + "/Data/headsq/quarter" )
self.reader.SetImageRange(1, 93)
self.reader.SetDataSpacing(3.2, 3.2, 1.5)
# self.addMetadata( self.reader.GetOutput() )
self.reader.AddObserver( "EndEvent", self.addMetadataObserver )
self.set3DOutput( port=self.reader.GetOutputPort() )
if self.dataset == 'iron':
self.reader = vtk.vtkStructuredPointsReader()
self.reader.SetFileName( VTK_DATA_ROOT + "/Data/ironProt.vtk" )
# self.addMetadata( self.reader.GetOutput() )
self.reader.AddObserver( "EndEvent", self.addMetadataObserver )
self.set3DOutput( port=self.reader.GetOutputPort() )
# if dataset == 'dust':
# filePath = os.path.normpath( "%s/../../data/DustCloud.nc" % packagePath )
# self.dataSet = Dataset( filePath, 'r' )
# self.variableList = self.dataSet.variables.keys()
# print " --- input vars: " + str( self.variableList )
# outputImage = vtk.vtkImageData()
# self.imageSource = vtk.vtkImageSource()
# self.imageSource.SetOutput( outputImage )
# return self.imageSource.GetOutputPort()
if self.dataset == 'wind':
# dataFile = "yotc_UV_1.nc"
# undefVal = -999000000.0
# invertZVal = False
# self.NCDR = NetCDFDataWrapper( dataFile, invertZ=invertZVal, undef=undefVal)
# outputImage = self.NCDR.GetFloatVectorImageData( [ "u", "v" ], 0, self.fieldData )
self.dataWrapper = GradsReader.GradsDataWrapper( glob='*e5ncep.*.ctl', TimeRange=[ 1, self.maxNTS ] )
self.timeSteps = self.dataWrapper.getTimeSteps()
self.imageData = self.dataWrapper.GetImageVectorData( self.fieldData, var=[ 'uf', 'vf', None ] )
self.set3DOutput( output=self.imageData )
if self.dataset == 'putman':
dataFile = "/Developer/Data/Putman/Fortuna-cubed-c2000_latlon.inst3_3d_asm1Np.20100208_0000z.nc"
undefVal = 1.0e15
invertZVal = False
self.NCDR = NetCDFDataWrapper( dataFile, invertZ=invertZVal, undef=undefVal)
outputImage = self.NCDR.GetShortImageData( "T", 0, self.fieldData )
self.set3DOutput( output=self.imageData )
if self.dataset == 'e5ncep':
self.dataWrapper = GradsReader.GradsDataWrapper( glob='*e5ncep.*.ctl', TimeRange=[ 1, self.maxNTS ] )
self.timeSteps = self.dataWrapper.getTimeSteps()
self.dataWrapper.SetCurrentVariable( 'tf', self.timeSteps[self.timeIndex] )
self.dataWrapper.ImportTimeSeries()
self.imageData = self.dataWrapper.GetImageData( self.fieldData )
# pointData = imageData.GetPointData()
# array0 = pointData.GetArray(0)
# printArgs( "GRADS IMAGE DATA", npts= imageData.GetNumberOfPoints(), ncells= imageData.GetNumberOfCells(), ncomp= imageData.GetNumberOfScalarComponents(), img_len= imageData.GetLength() )
# printArgs( "GRADS IMAGE EXT", extent= imageData.GetExtent(), spacing= imageData.GetSpacing(), origin= imageData.GetOrigin(), dim= imageData.GetDimensions() )
# printArgs( "GRADS POINT DATA", ntup= pointData.GetNumberOfTuples(), narrays= pointData.GetNumberOfArrays(), ncomp= pointData.GetNumberOfComponents())
# printArgs( "GRADS Array DATA", ntup= array0.GetNumberOfTuples(), size= array0.GetSize(), dsize= array0.GetDataSize(), range= array0.GetRange(), maxid= array0.GetMaxId(), ncomp= array0.GetNumberOfComponents() )
self.set3DOutput( output=self.imageData )
开发者ID:imclab,项目名称:vistrails,代码行数:66,代码来源:DemoDataModule.py
注:本文中的vtk.vtkVolume16Reader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论