本文整理汇总了Python中vtk.vtkImageReader函数的典型用法代码示例。如果您正苦于以下问题:Python vtkImageReader函数的具体用法?Python vtkImageReader怎么用?Python vtkImageReader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkImageReader函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkImageReader(), 'Reading vtkImage.',
(), ('vtkImage',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkImageReader.py
示例2: transform_polydata_from_disk
def transform_polydata_from_disk(in_filename, transform_filename, out_filename):
# Read it in.
print "<io.py> Transforming ", in_filename, "->", out_filename, "..."
# Read the transform from disk because we cannot pickle it
(root, ext) = os.path.splitext(transform_filename)
print root, ext
if ext == '.xfm':
reader = vtk.vtkMNITransformReader()
reader.SetFileName(transform_filename)
reader.Update()
transform = reader.GetTransform()
elif ext == '.img':
reader = vtk.vtkImageReader()
reader.SetFileName(transform_filename)
reader.Update()
coeffs = reader.GetOutput()
transform = vtk.vtkBSplineTransform()
transform.SetCoefficients(coeffs)
print coeffs
print transform
else:
f = open(transform_filename, 'r')
transform = vtk.vtkTransform()
matrix = vtk.vtkMatrix4x4()
for i in range(0,4):
for j in range(0,4):
matrix_val = float(f.readline())
matrix.SetElement(i,j, matrix_val)
transform.SetMatrix(matrix)
del matrix
start_time = time.time()
pd = read_polydata(in_filename)
elapsed_time = time.time() - start_time
print "READ:", elapsed_time
# Transform it.
start_time = time.time()
transformer = vtk.vtkTransformPolyDataFilter()
if (vtk.vtkVersion().GetVTKMajorVersion() >= 6.0):
transformer.SetInputData(pd)
else:
transformer.SetInput(pd)
transformer.SetTransform(transform)
transformer.Update()
elapsed_time = time.time() - start_time
print "TXFORM:", elapsed_time
# Write it out.
start_time = time.time()
pd2 = transformer.GetOutput()
write_polydata(pd2, out_filename)
elapsed_time = time.time() - start_time
print "WRITE:", elapsed_time
# Clean up.
del transformer
del pd2
del pd
del transform
开发者ID:SlicerDMRI,项目名称:whitematteranalysis,代码行数:60,代码来源:io.py
示例3: read_all_images
def read_all_images(image_files):
image_list = list()
for fname in image_files:
print "Reading:", fname
reader = vtk.vtkImageReader()
# if they gave us a nhdr get the raw file,
# this is very basic
basename, extension = os.path.splitext(fname)
if extension == '.nhdr':
fname = basename + '.raw'
print fname
reader.SetFileName(fname)
# header info (should be same for ALL TBI/control data)
#reader.SetDataScalarTypeToShort()
reader.SetDataScalarTypeToFloat()
reader.SetDataSpacing(1.6667, 1.6667, 1.7)
reader.SetDataOrigin(119.169, 119.169, 71.4)
reader.SetDataByteOrderToLittleEndian()
#reader.SetDataExtent(0, 144, 0, 144, 0, 85)
reader.SetDataExtent(0, 143, 0, 143, 0, 84)
reader.SetFileDimensionality(3)
reader.Update()
image_list.append(reader.GetOutput())
del reader
return image_list
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:25,代码来源:test_read_vol.py
示例4: get_reader
def get_reader(file_prefix):
reader = vtk.vtkImageReader()
reader.SetFilePrefix(file_prefix)
reader.SetFilePattern('%s%03d.raw')
reader.SetDataScalarTypeToUnsignedChar()
reader.SetFileDimensionality(2)
reader.SetDataSpacing(1,1,1.5)
reader.SetDataExtent(0,499,0,469,1,136)
reader.Update()
return reader
开发者ID:louissmit,项目名称:SVVR,代码行数:10,代码来源:exercise4.py
示例5: testAll
def testAll(self):
reader = vtk.vtkImageReader()
reader.SetDataByteOrderToLittleEndian()
reader.SetDataExtent(0,63,0,63,1,93)
reader.SetDataSpacing(3.2,3.2,1.5)
reader.SetFilePrefix("" + str(VTK_DATA_ROOT) + "/Data/headsq/quarter")
reader.SetDataMask(0x7fff)
# write isosurface to file
#vtkSynchronizedTemplates3D stemp
stemp = vtk.vtkContourFilter()
stemp.SetInputConnection(reader.GetOutputPort())
stemp.SetValue(0,1150)
stemp.GenerateTrianglesOff()
stemp.Update()
self.failUnlessEqual(stemp.GetOutputDataObject(0).GetNumberOfPoints(),39315)
self.failUnlessEqual(stemp.GetOutputDataObject(0).GetNumberOfCells(),38380)
stemp.GenerateTrianglesOn()
stemp.Update()
self.failUnlessEqual(stemp.GetOutputDataObject(0).GetNumberOfPoints(),39315)
self.failUnlessEqual(stemp.GetOutputDataObject(0).GetNumberOfCells(),78268)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(stemp.GetOutputPort())
mapper.ScalarVisibilityOff()
head = vtk.vtkActor()
head.SetMapper(mapper)
head.GetProperty().SetColor(1,0.7,0.6)
# Create the RenderWindow, Renderer and Interactor
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(head)
ren1.SetBackground(1,1,1)
renWin.SetSize(400,400)
ren1.SetBackground(0.5,0.5,0.6)
ren1.GetActiveCamera().SetPosition(99.8847,537.926,15)
ren1.GetActiveCamera().SetFocalPoint(99.8847,109.81,15)
ren1.GetActiveCamera().SetViewAngle(20)
ren1.GetActiveCamera().SetViewUp(0,0,-1)
ren1.ResetCameraClippingRange()
# render the image
#
renWin.Render()
开发者ID:0004c,项目名称:VTK,代码行数:50,代码来源:TestSynchronizedTemplates3D.py
示例6: __init__
def __init__(self, module_manager):
# call parent constructor
ModuleBase.__init__(self, module_manager)
self._reader = vtk.vtkImageReader()
self._reader.SetFileDimensionality(3)
# FIXME: make configurable (or disable)
#self._reader.SetFileLowerLeft(1)
module_utils.setup_vtk_object_progress(self, self._reader,
'Reading raw volume data')
self._dataTypes = {'Double': vtk.VTK_DOUBLE,
'Float' : vtk.VTK_FLOAT,
'Long' : vtk.VTK_LONG,
'Unsigned Long' : vtk.VTK_UNSIGNED_LONG,
'Integer' : vtk.VTK_INT,
'Unsigned Integer' : vtk.VTK_UNSIGNED_INT,
'Short' : vtk.VTK_SHORT,
'Unsigned Short' : vtk.VTK_UNSIGNED_SHORT,
'Char' : vtk.VTK_CHAR,
'Unsigned Char' : vtk.VTK_UNSIGNED_CHAR}
self._viewFrame = None
# now setup some defaults before our sync
self._config.filename = ''
self._config.dataType = self._reader.GetDataScalarType()
# 1 is little endian
self._config.endianness = 1
self._config.headerSize = 0
self._config.extent = (0, 128, 0, 128, 0, 128)
self._config.spacing = (1.0, 1.0, 1.0)
self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:38,代码来源:rawVolumeRDR.py
示例7: ReadAnalyze
def ReadAnalyze(filename):
print "Reading analyze file:", filename
# Reading info from analyze header
header_file = open(filename)
header = AnalyzeHeader.from_fileobj(header_file)
xf, yf, zf = header.get_data_shape()[:3]
data_type = header.get_data_dtype().name
pixel_spacing = header.get_zooms()[:3]
# Mapping from numpy type to vtk type.
anlz_2_vtk_type = {
'int16': 'SetDataScalarTypeToShort',
'uint16': 'SetDataScalarTypeToUnsignedShort',
'float32': 'SetDataScalarTypeToFloat'
}
print header
reader = vtk.vtkImageReader()
reader.SetFileName(filename[:-3] + 'img')
# Setting the endiannes based on the analyze header.
if header.endianness == '<':
reader.SetDataByteOrderToLittleEndian()
elif header.endianness == '>':
reader.SetDataByteOrderToBigEndian()
reader.SetFileDimensionality(3)
reader.SetDataExtent(0, xf-1, 0, yf-1, 0, zf-1)
reader.SetDataSpacing(pixel_spacing)
reader.SetHeaderSize(0)
# reader.SetTransform(transform)
getattr(reader, anlz_2_vtk_type[data_type])()
reader.Update()
return reader.GetOutput()
开发者ID:151706061,项目名称:invesalius,代码行数:37,代码来源:analyze_reader.py
示例8: ReadRawImageFile
def ReadRawImageFile(self):
if (self.InputFileName == '') & (self.InputFilePrefix == ''):
self.PrintError('Error: no InputFileName or InputFilePrefix.')
self.PrintLog('Reading RAW image file.')
reader = vtk.vtkImageReader()
if self.InputFileName != '':
reader.SetFileName(self.InputFileName)
else:
reader.SetFilePrefix(self.InputFilePrefix)
if self.InputFilePattern != '':
reader.SetFilePattern(self.InputFilePattern)
else:
reader.SetFilePattern("%s%04d.png")
reader.SetFileDimensionality(self.FileDimensionality)
if self.DataByteOrder == 'littleendian':
reader.SetDataByteOrderToLittleEndian()
elif self.DataByteOrder == 'bigendian':
reader.SetDataByteOrderToBigEndian()
reader.SetDataExtent(self.DataExtent)
reader.SetDataSpacing(self.DataSpacing)
reader.SetDataOrigin(self.DataOrigin)
reader.SetHeaderSize(self.HeaderSize)
if self.DataScalarType == 'float':
reader.SetDataScalarTypeToFloat()
elif self.DataScalarType == 'double':
reader.SetDataScalarTypeToDouble()
elif self.DataScalarType == 'int':
reader.SetDataScalarTypeToInt()
elif self.DataScalarType == 'short':
reader.SetDataScalarTypeToShort()
elif self.DataScalarType == 'ushort':
reader.SetDataScalarTypeToUnsignedShort()
elif self.DataScalarType == 'uchar':
reader.SetDataScalarTypeToUnsignedChar()
reader.Update()
self.Image = reader.GetOutput()
开发者ID:vmtk,项目名称:vmtk,代码行数:36,代码来源:vmtkimagereader.py
示例9: vtkTkRenderWidget
16: "Skin",
}
# Deze kleuren zijn nog niet allemaal goed. Sommigen zijn dubbel!
root = Tkinter.Tk()
aRenderer = vtk.vtkRenderer()
aRenderer.TexturedBackgroundOn()
renderWidget = vtkTkRenderWidget(root, width=800, height=600)
renderWidget.pack(expand="true", fill="both")
renWin = renderWidget.GetRenderWindow()
renWin.AddRenderer(aRenderer)
aRenderer.SetBackground(1, 1, 1)
renWin.SetSize(600, 480)
reader = vtk.vtkImageReader()
reader.SetDataExtent(0, 499, 0, 469, 1, 136)
reader.SetDataSpacing(1, 1, 1.5)
reader.SetDataScalarTypeToUnsignedChar()
reader.SetFilePattern("./WholeFrog/frogTissue.%s%03d.raw")
reader.Update()
readerSkin = vtk.vtkImageReader()
readerSkin.SetDataExtent(0, 499, 0, 469, 1, 136)
readerSkin.SetDataSpacing(1, 1, 1.5)
readerSkin.SetDataScalarTypeToUnsignedChar()
readerSkin.SetFilePattern("./WholeFrog/frog.%s%03d.raw")
readerSkin.Update()
createVolumeDict()
开发者ID:JaroCamphuijsen,项目名称:SVVR,代码行数:30,代码来源:Assignment4_old.py
示例10: vtkGetDataRoot
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Image pipeline
reader = vtk.vtkImageReader()
reader.ReleaseDataFlagOff()
reader.SetDataByteOrderToLittleEndian()
reader.SetDataExtent(0,63,0,63,1,93)
reader.SetDataSpacing(3.2,3.2,1.5)
reader.SetDataOrigin(-100.8,-100.8,-69)
reader.SetFilePrefix("" + str(VTK_DATA_ROOT) + "/Data/headsq/quarter")
reader.SetDataMask(0x7fff)
reader.Update()
p1 = vtk.vtkPoints()
p2 = vtk.vtkPoints()
p1.InsertNextPoint(0,0,0)
p2.InsertNextPoint(-60,10,20)
p1.InsertNextPoint(-100,-100,-50)
p2.InsertNextPoint(-100,-100,-50)
p1.InsertNextPoint(-100,-100,50)
p2.InsertNextPoint(-100,-100,50)
p1.InsertNextPoint(-100,100,-50)
p2.InsertNextPoint(-100,100,-50)
p1.InsertNextPoint(-100,100,50)
p2.InsertNextPoint(-100,100,50)
p1.InsertNextPoint(100,-100,-50)
p2.InsertNextPoint(100,-100,-50)
p1.InsertNextPoint(100,-100,50)
p2.InsertNextPoint(100,-100,50)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:TestGridWarp3D.py
示例11: testThreshold
def testThreshold(self):
# This script is for testing the 3D threshold filter.
# Image pipeline
renWin = vtk.vtkRenderWindow()
renWin.SetSize(192, 256)
reader = vtk.vtkImageReader()
reader.ReleaseDataFlagOff()
reader.SetDataByteOrderToLittleEndian()
reader.SetDataExtent(0, 63, 0, 63, 1, 93)
reader.SetDataSpacing(3.2, 3.2, 1.5)
reader.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
reader.SetDataMask(0x7fff)
outputtype = ["SignedChar", "UnsignedChar", "Long", "UnsignedLong", "Int", "UnsignedInt",
"Short", "UnsignedShort", "Double", "Float", "Double", "Float"]
replacein = ["ReplaceInOn", "ReplaceInOff"]
replaceout = ["ReplaceOutOn", "ReplaceOutOff"]
thresholds = ["ThresholdByLower(800)", "ThresholdByUpper(1200)", "ThresholdBetween(800, 1200)"]
thresh = list()
map = list()
act = list()
ren = list()
k = 0
for rin in replacein:
for rout in replaceout:
for t in thresholds:
thresh.append(vtk.vtkImageThreshold())
thresh[k].SetInValue(2000)
thresh[k].SetOutValue(0)
eval('thresh[k].' + rin + '()')
eval('thresh[k].' + rout + '()')
thresh[k].SetInputConnection(reader.GetOutputPort())
eval('thresh[k].' + t)
eval('thresh[k].SetOutputScalarTypeTo' + outputtype[k] + '()')
map.append(vtk.vtkImageMapper())
map[k].SetInputConnection(thresh[k].GetOutputPort())
if k < 3:
map[k].SetColorWindow(255)
map[k].SetColorLevel(127.5)
else:
map[k].SetColorWindow(2000)
map[k].SetColorLevel(1000)
act.append(vtk.vtkActor2D())
act[k].SetMapper(map[k])
ren.append(vtk.vtkRenderer())
ren[k].AddActor2D(act[k])
renWin.AddRenderer(ren[k])
k += 1
ren[0].SetViewport(0, 0, .33333, .25)
ren[1].SetViewport(.33333, 0, .66667, .25)
ren[2].SetViewport(.66667, 0, 1, .25)
ren[3].SetViewport(0, .25, .33333, .5)
ren[4].SetViewport(.33333, .25, .66667, .5)
ren[5].SetViewport(.66667, .25, 1, .5)
ren[6].SetViewport(0, .5, .33333, .75)
ren[7].SetViewport(.33333, .5, .66667, .75)
ren[8].SetViewport(.66667, .5, 1, .75)
ren[9].SetViewport(0, .75, .33333, 1)
ren[10].SetViewport(.33333, .75, .66667, 1)
ren[11].SetViewport(.66667, .75, 1, 1)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestThreshold.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:83,代码来源:TestThreshold.py
示例12: vis_imgInit
def vis_imgInit(ren):
rdr = [None]*2
txt = [None]*2
plane = [None]*2
tmap = [None]*2
cast = [None]*2
vmap = [None]*2
actor = [None]*2
lookupGrayscale = [None]*2
lookupColor = [None]*2
rdr[0] = 'vis_img_reader_' + ren[0]
txt[0] = 'vis_img_texture_' + ren[0]
plane[0] = 'vis_img_plane_' + ren[0]
tmap[0] = 'vis_img_tmap_' + ren[0]
vmap[0] = 'vis_img_map_' + ren[0]
actor[0] = 'vis_img_actor_' + ren[0]
lookupGrayscale[0] = 'vis_img_g8bitGrayscaleLUT_' + ren[0]
lookupColor[0] = 'vis_img_gBlueToRedLUT_'+ ren[0]
rdr[1] = vtk.vtkImageReader()
rdr[1].SetDataScalarTypeToShort()
rdr[1].SetFileDimensionality(2)
rdr[1].SetDataByteOrderToBigEndian()
txt[1] = vtk.vtkTexture()
plane[1] = vtk.vtkPlaneSource()
plane[1].SetResolution(1,1)
plane[1].SetOrigin(0.,0.,0.)
tmap[1] = vtk.vtkTextureMapToPlane()
tmap[1].SetInputConnection(plane[1].GetOutputPort())
cast[1] = vtk.vtkCastToConcrete()
cast[1].SetInputConnection(tmap[1].GetOutputPort())
vmap[1] = vtk.vtkPolyDataMapper()
vmap[1].SetInputConnection(cast[1].GetOutputPort())
actor[1] = vtk.vtkActor()
actor[1].SetMapper(vmap[1])
actor[1].SetTexture(txt[1])
lookupGrayscale[1] = vtk.vtkLookupTable()
lookupGrayscale[1].SetHueRange(0.,0.)
lookupGrayscale[1].SetSaturationRange(0.,0.)
lookupGrayscale[1].SetValueRange(0.,1.)
lookupGrayscale[1].SetNumberOfColors(16384)
lookupGrayscale[1].Build()
lookupColor[1] = vtk.vtkLookupTable()
lookupColor[1].SetHueRange(0.6667,0.)
lookupColor[1].SetSaturationRange(1.,1.)
lookupColor[1].SetValueRange(1.,1.)
lookupColor[1].SetAlphaRange(1.,1.)
lookupColor[1].SetNumberOfColors(16384)
lookupColor[1].Build()
setattr(vis,rdr[0], rdr)
setattr(vis,txt[0], txt)
setattr(vis,plane[0], plane)
setattr(vis,tmap[0], tmap)
setattr(vis,vmap[0], vmap)
setattr(vis,actor[0], actor)
setattr(vis,lookupGrayscale[0], lookupGrayscale)
setattr(vis,lookupColor[0], lookupColor)
return
开发者ID:osmsc,项目名称:SimVascular,代码行数:67,代码来源:img.py
示例13:
import Tkinter
import vtk
from vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor
# Prepare to read the file
readerVolume = vtk.vtkImageReader()
readerVolume.SetDataScalarType( vtk.VTK_UNSIGNED_SHORT )
readerVolume.SetFileDimensionality( 3 )
readerVolume.SetDataExtent ( 0,255, 0,255, 0,576)
readerVolume.SetDataSpacing( 1,1,1 )
readerVolume.SetNumberOfScalarComponents( 1 )
readerVolume.SetDataByteOrderToBigEndian()
readerVolume.SetFileName( "./Female.raw" )
# Extract the region of interest
voiHead = vtk.vtkExtractVOI()
voiHead.SetInput( readerVolume.GetOutput() )
voiHead.SetVOI( 0,255, 60,255, 0,100 )
voiHead.SetSampleRate( 1,1,1 )
# Generate an isosurface
# UNCOMMENT THE FOLLOWING LINE FOR CONTOUR FILTER
# contourBoneHead = vtk.vtkContourFilter()
contourBoneHead = vtk.vtkMarchingCubes()
contourBoneHead.SetInput( voiHead.GetOutput() )
contourBoneHead.ComputeNormalsOn()
contourBoneHead.SetValue( 0, 1250 ) # Bone isovalue
# Take the isosurface data and create geometry
geoBoneMapper = vtk.vtkPolyDataMapper()
geoBoneMapper.SetInput( contourBoneHead.GetOutput() )
开发者ID:quakberto,项目名称:quantification,代码行数:31,代码来源:delme2.py
示例14: testAllShrinks
def testAllShrinks(self):
prefix = VTK_DATA_ROOT + "/Data/headsq/quarter"
renWin = vtk.vtkRenderWindow()
# Image pipeline
reader = vtk.vtkImageReader()
reader.SetDataExtent(0, 63, 0, 63, 1, 93)
reader.SetFilePrefix(prefix)
reader.SetDataByteOrderToLittleEndian()
reader.SetDataMask(0x7fff)
factor = 4
magFactor = 8
ops = ["Minimum", "Maximum", "Mean", "Median", "NoOp"]
shrink = dict()
mag = dict()
mapper = dict()
actor = dict()
imager = dict()
for operator in ops:
shrink.update({operator:vtk.vtkImageShrink3D()})
shrink[operator].SetMean(0)
if operator != "NoOp":
eval('shrink[operator].' + operator + 'On()')
shrink[operator].SetShrinkFactors(factor, factor, factor)
shrink[operator].SetInputConnection(reader.GetOutputPort())
mag.update({operator:vtk.vtkImageMagnify()})
mag[operator].SetMagnificationFactors(magFactor, magFactor, magFactor)
mag[operator].InterpolateOff()
mag[operator].SetInputConnection(shrink[operator].GetOutputPort())
mapper.update({operator:vtk.vtkImageMapper()})
mapper[operator].SetInputConnection(mag[operator].GetOutputPort())
mapper[operator].SetColorWindow(2000)
mapper[operator].SetColorLevel(1000)
mapper[operator].SetZSlice(45)
actor.update({operator:vtk.vtkActor2D()})
actor[operator].SetMapper(mapper[operator])
imager.update({operator:vtk.vtkRenderer()})
imager[operator].AddActor2D(actor[operator])
renWin.AddRenderer(imager[operator])
shrink["Minimum"].Update
shrink["Maximum"].Update
shrink["Mean"].Update
shrink["Median"].Update
imager["Minimum"].SetViewport(0, 0, .5, .33)
imager["Maximum"].SetViewport(0, .33, .5, .667)
imager["Mean"].SetViewport(.5, 0, 1, .33)
imager["Median"].SetViewport(.5, .33, 1, .667)
imager["NoOp"].SetViewport(0, .667, 1, 1)
renWin.SetSize(256, 384)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestAllShrinks.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:70,代码来源:TestAllShrinks.py
示例15:
# frogMapper.SetInputConnection(frogReader.GetOutputPort())
# frogMapper.SetVolumeRayCastFunction(frogFunc)
# frogVolProp = vtk.vtkVolumeProperty()
# frogVolProp.SetColor(frogClr)
# frogVolProp.SetScalarOpacity(frogDens)
# frogVolProp.SetInterpolationTypeToLinear()
# frogVolProp.ShadeOn()
# frog = vtk.vtkVolume()
# frog.SetMapper(frogMapper)
# frog.SetProperty(frogVolProp)
# frog.RotateY(180)
# Frog's tissues
tissueReader = vtk.vtkImageReader()
tissueReader.SetDataByteOrderToLittleEndian()
tissueReader.SetDataExtent(0, 499, 0, 469, 1, 136)
tissueReader.SetDataSpacing(1, 1, 1.5)
tissueReader.SetDataScalarTypeToUnsignedChar()
tissueReader.SetFileDimensionality(2)
tissueReader.SetFilePrefix("./WholeFrog/frogTissue.")
tissueReader.SetFilePattern("%s%03d.raw")
tissueReader.Update()
frogDens = vtk.vtkPiecewiseFunction()
frogDens.AddPoint(0.0, 0.0)
frogDens.AddPoint(60.0, 0.0)
frogDens.AddPoint(110.0, 0.02)
frogDens.AddPoint(150.0, 0.05)
frogDens.AddPoint(200.0, 0.1)
开发者ID:HighExecutor,项目名称:vtkFrogAtlas,代码行数:31,代码来源:frog_copy.py
示例16: execute_module
def execute_module(self):
if self._imageInput and self._meshInput:
# basename for all CPT files
cptBaseName = os.tempnam()
# first convert mesh data to brep
cbw = self._module_manager.create_module(
'modules.writers.cptBrepWRT')
cbw.set_input(0, self._meshInput)
cfg = cbw.get_config()
brepFilename = '%s.brep' % (cptBaseName,)
cfg.filename = brepFilename
cbw.set_config(cfg)
# we're calling it directly... propagations will propagate
# upwards to our caller (the ModuleManager) - execution
# will be interrupted if cbw flags an error
cbw.execute_module()
# now let's write the geom file
self._imageInput.UpdateInformation()
b = self._imageInput.GetBounds()
d = self._imageInput.GetDimensions()
geomFile = file('%s.geom' % (cptBaseName,), 'w')
# bounds
geomFile.write('%f %f %f %f %f %f\n' % (b[0], b[2], b[4],
b[1], b[3], b[5]))
# dimensions
geomFile.write('%d %d %d\n' % (d[0], d[1], d[2]))
# maximum distance
geomFile.write('%d\n' % (self._config.max_distance,))
# must be signed
geomFile.write('1\n')
geomFile.close()
# now we can call the driver
os.system('%s -b -o %s %s.geom %s.brep' % \
(self._config.cpt_driver_path,
cptBaseName, cptBaseName, cptBaseName))
# we should have cptBaseName.dist waiting...
reader = vtk.vtkImageReader()
reader.SetFileName('%s.dist' % (cptBaseName,))
reader.SetFileDimensionality(3)
reader.SetDataScalarType(vtk.VTK_DOUBLE)
# 3 doubles in header
reader.SetHeaderSize(24)
reader.SetDataExtent(self._imageInput.GetWholeExtent())
reader.SetDataSpacing(self._imageInput.GetSpacing())
module_utils.setup_vtk_object_progress(
self, reader, 'Reading CPT distance field output.')
self._flipper.SetInput(reader.GetOutput())
self._flipper.GetOutput().UpdateInformation()
self._flipper.GetOutput().SetUpdateExtentToWholeExtent()
self._flipper.Update()
self._module_manager.delete_module(cbw)
print "CPT Basename == %s" % (cptBaseName,)
开发者ID:fvpolpeta,项目名称:devide,代码行数:61,代码来源:cptDistanceField.py
注:本文中的vtk.vtkImageReader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论