本文整理汇总了Python中vtk.vtkXMLImageDataWriter函数的典型用法代码示例。如果您正苦于以下问题:Python vtkXMLImageDataWriter函数的具体用法?Python vtkXMLImageDataWriter怎么用?Python vtkXMLImageDataWriter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkXMLImageDataWriter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: write_vtk
def write_vtk(self, DX=2.0, DY=2.0, DZ=0.05):
"""Reads cell data from vals array and writes into a VTK file called
'Stratal_Arch.vti' and is a structure grid object. Spacing defaults
are 2.0/2.0/0.05"""
vtk_obj = vtkImageData()
vtk_obj.SetSpacing(DX, DY, DZ)
vtk_obj.SetDimensions(self.dims[0]+1, self.dims[1]+1, self.dims[2]+1)
# Start writing from the top of the object to match output from Eclipse
vtk_obj.SetOrigin(0, 0, self.dims[2]+1)
array = vtkIntArray()
array.SetName("Stratal Architecture")
array.SetNumberOfComponents(1)
for z in range(0, self.dims[2]):
for y in range(0, self.dims[1]):
for x in range(0, self.dims[0]):
val = self.vals[x][y][z]
array.InsertNextTuple1(val)
vtk_obj.GetCellData().AddArray(array)
vtk_f = vtkXMLImageDataWriter()
vtk_f.SetFileName("Stratal_Arch.vti")
vtk_f.SetInputData(vtk_obj)
vtk_f.Write()
开发者ID:crappyoats,项目名称:indicator_read,代码行数:28,代码来源:BinaryGrid.py
示例2: dicom_to_vti
def dicom_to_vti(imagedata, filename):
logging.debug("In data.dicom_to_vti()")
extent = imagedata.GetWholeExtent()
spacing = imagedata.GetSpacing()
origin = imagedata.GetOrigin()
center = (
origin[0] + spacing[0] * 0.5 * (extent[0] + extent[1]),
origin[1] + spacing[1] * 0.5 * (extent[2] + extent[3]),
origin[2] + spacing[2] * 0.5 * (extent[4] + extent[5]),
)
resliceAxes = vtk.vtkMatrix4x4()
vtkMatrix = (1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
resliceAxes.DeepCopy(vtkMatrix)
resliceAxes.SetElement(0, 3, center[0])
resliceAxes.SetElement(1, 3, center[1])
resliceAxes.SetElement(2, 3, center[2])
reslice = vtk.vtkImageReslice()
reslice.SetInput(imagedata)
reslice.SetInformationInput(imagedata)
reslice.SetResliceAxes(resliceAxes)
reslice.SetOutputDimensionality(3)
reslice.Update()
imagedata = reslice.GetOutput()
writer = vtk.vtkXMLImageDataWriter()
writer.SetInput(imagedata)
writer.SetFileName(filename)
writer.Write()
开发者ID:aevum,项目名称:moonstone,代码行数:31,代码来源:data.py
示例3: save_to_vti
def save_to_vti(imagedata, file_output):
print("Saving")
w = vtk.vtkXMLImageDataWriter()
w.SetInputData(imagedata)
w.SetFileName(file_output)
w.Write()
print("Saved")
开发者ID:tfmoraes,项目名称:smooth_c,代码行数:7,代码来源:smooth_vti.py
示例4: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkXMLImageDataWriter(), 'Writing vtkXMLImageData.',
('vtkXMLImageData',), (),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkXMLImageDataWriter.py
示例5: write_data
def write_data(data,x,y,z):
siz = x*y*z
fs="%dH"%siz
print "min(data)=",min(data),"max(data)=",max(data)
print "size=",siz,"len of data=",len(data)
ss = struct.pack(fs,*data)
print "min(ss)=",min(ss),"max(ss)=",max(ss),"len(ss)=",len(ss)
importer=vtk.vtkImageImport()
importer.CopyImportVoidPointer(ss,len(ss))
importer.SetDataScalarTypeToUnsignedShort()
#importer.SetDataScalarTypeToUnsignedChar()
#importer.SetDataScalarType(5)
importer.SetNumberOfScalarComponents(1)
importer.SetDataExtent(0,x-1,0,y-1,0,z-1)
importer.SetWholeExtent(0,x-1,0,y-1,0,z-1)
importer.Update()
image = importer.GetOutput()
#print image
print "Image scalar range=",image.GetScalarRange()
print "Image scalar type=",image.GetScalarTypeAsString()
#print image
writer = vtk.vtkXMLImageDataWriter()
writer.SetInput(image)
writer.SetFileName("output.vti")
print "Writing..."
writer.Write()
print "done"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:30,代码来源:test_plot_track.py
示例6: Export
def Export(imagedata, filename, bin=False):
writer = vtk.vtkXMLImageDataWriter()
writer.SetFileName(filename)
if bin:
writer.SetDataModeToBinary()
else:
writer.SetDataModeToAscii()
开发者ID:paulojamorim,项目名称:invesalius3,代码行数:7,代码来源:imagedata_utils.py
示例7: __del__
def __del__(self):
if self._needWrite:
import vtk
vw = vtk.vtkXMLImageDataWriter()
vw.SetFileName(self._vol_file)
vw.SetInputData(self._volume)
vw.Write()
开发者ID:edgar-mtz-e,项目名称:ParaView,代码行数:7,代码来源:cinema_store.py
示例8: _handlerVoiSaveButton
def _handlerVoiSaveButton(self, event):
input_data = self.getPrimaryInput()
filename = self.controlFrame.voiFilenameText.GetValue()
if input_data and self._voi_widget.GetEnabled() and filename:
# see if we need to reset to zero origin
zor = self.controlFrame.voiResetToOriginCheck.GetValue()
extractVOI = vtk.vtkExtractVOI()
extractVOI.SetInput(input_data)
extractVOI.SetVOI(self._currentVOI)
writer = vtk.vtkXMLImageDataWriter()
writer.SetDataModeToBinary()
writer.SetFileName(filename)
if zor:
ici = vtk.vtkImageChangeInformation()
ici.SetOutputExtentStart(0,0,0)
ici.SetInput(extractVOI.GetOutput())
writer.SetInput(ici.GetOutput())
else:
writer.SetInput(extractVOI.GetOutput())
writer.Write()
开发者ID:sanguinariojoe,项目名称:devide,代码行数:25,代码来源:slice3dVWR.py
示例9: __init__
def __init__(self, module_manager):
# call parent constructor
ModuleBase.__init__(self, module_manager)
self._writer = vtk.vtkXMLImageDataWriter()
# ctor for this specific mixin
FilenameViewModuleMixin.__init__(
self,
'Select a filename',
'VTK Image Data (*.vti)|*.vti|All files (*)|*',
{'vtkXMLImageDataWriter': self._writer},
fileOpen=False)
module_utils.setup_vtk_object_progress(
self, self._writer,
'Writing VTK ImageData')
self._writer.SetDataModeToBinary()
# set up some defaults
self._config.filename = ''
self._module_manager.sync_module_logic_with_config(self)
开发者ID:fvpolpeta,项目名称:devide,代码行数:26,代码来源:vtiWRT.py
示例10: WriteVTKXMLImageFile
def WriteVTKXMLImageFile(self):
if self.OutputFileName == "":
self.PrintError("Error: no OutputFileName.")
self.PrintLog("Writing VTK XML image file.")
writer = vtk.vtkXMLImageDataWriter()
writer.SetInput(self.Image)
writer.SetFileName(self.OutputFileName)
writer.Write()
开发者ID:abhishek101hi,项目名称:vmtk,代码行数:8,代码来源:vmtkimagewriter.py
示例11: WriteVTKXMLImageFile
def WriteVTKXMLImageFile(self):
if (self.OutputFileName == ''):
self.PrintError('Error: no OutputFileName.')
self.PrintLog('Writing VTK XML image file.')
writer = vtk.vtkXMLImageDataWriter()
writer.SetInputData(self.Image)
writer.SetFileName(self.OutputFileName)
writer.Write()
开发者ID:vmtk,项目名称:vmtk,代码行数:8,代码来源:vmtkimagewriter.py
示例12: write_to_file
def write_to_file(self, fname):
if self.__data is not None:
writer = vtk.vtkXMLImageDataWriter()
writer.SetFileName(fname)
writer.SetInput(self.__data)
writer.Write()
else:
print "vtk object does not exist. Use VTKStructuredPoints.create_vtk_structured_points to initialize it"
开发者ID:tbetcke,项目名称:PyPWDG,代码行数:9,代码来源:vtk_output.py
示例13: write_sp
def write_sp(pd):
writer = vtk.vtkXMLImageDataWriter()
writer.SetFileName("mean_flow.vti")
if vtk.vtkVersion.GetVTKMajorVersion() <= 5:
writer.SetInput(pd)
else:
writer.SetInputData(pd)
writer.Write()
return
开发者ID:Torgier,项目名称:fluidity,代码行数:9,代码来源:mean_flow.py
示例14: keyPressEvent
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Space:
if event.modifiers() == QtCore.Qt.NoModifier:
self.WordleView.Modified()
self.WordleView.Update()
elif event.modifiers() == QtCore.Qt.ShiftModifier:
self.table.Modified()
self.WordleView.Update()
# Change Fonts (f)
if event.key() == QtCore.Qt.Key_F:
if self.font_flag:
self.WordleView.SetFontFamily("Tekton Pro")
else:
self.WordleView.SetFontFamily("Rockwell")
self.font_flag = not self.font_flag
self.WordleView.Update()
# Write PNG (n)
# Trying to use a integer-based QImage
if event.key() == QtCore.Qt.Key_N:
self.WordleView.SaveImage("out.png")
# Grab ImageData (i)
if event.key() == QtCore.Qt.Key_I:
image = self.WordleView.GetImageData()
# print image
iw = vtk.vtkXMLImageDataWriter()
iw.SetInput(image)
iw.SetFileName("out.vti")
iw.Write()
# Write PDF (p)
if event.key() == QtCore.Qt.Key_P:
self.WordleView.SavePDF("out.pdf")
# Write SVG (s)
# SVG generation not compiled in by default...
# if event.key() == QtCore.Qt.Key_S:
# self.WordleView.SaveSVG("out.svg")
# Switch only colors
if event.key() == QtCore.Qt.Key_C:
self.color_by_array = not self.color_by_array
if event.modifiers() == QtCore.Qt.NoModifier:
self.WordleView.SetColorByArray(self.color_by_array)
self.WordleView.Update()
elif event.modifiers() == QtCore.Qt.ShiftModifier:
if self.color_by_array:
self.WordleView.ApplyViewTheme(self.vt)
else:
self.WordleView.ApplyViewTheme(self.vt2)
self.WordleView.Update()
开发者ID:emonson,项目名称:vtkVTG,代码行数:53,代码来源:QtWordleView.py
示例15: vtkImageData2vti
def vtkImageData2vti(filePath, source):
"""Export a ``vtk.vtkImageData`` object to VTI file.
Parameters
----------
filePath : str
Full path for the VTI to be created.
source : vtk.vtkImageData
object.
"""
writer = vtk.vtkXMLImageDataWriter()
writer.SetFileName(filePath)
writer.SetInput(source)
writer.Write()
开发者ID:AlfiyaZi,项目名称:Py3DFreeHandUS,代码行数:16,代码来源:voxel_array_utils.py
示例16: writeImage
def writeImage(
image,
filename,
verbose=1):
myVTK.myPrint(verbose, "*** writeImage: " + filename + " ***")
if ('vtk' in filename):
image_writer = vtk.vtkImageWriter()
elif ('vti' in filename):
image_writer = vtk.vtkXMLImageDataWriter()
else:
assert 0, "File must be .vtk or .vti. Aborting."
image_writer.SetFileName(filename)
image_writer.SetInputData(image)
image_writer.Update()
image_writer.Write()
开发者ID:gacevedobolton,项目名称:myVTKPythonLibrary,代码行数:18,代码来源:writeImage.py
示例17: save_image_data
def save_image_data(handle, image_data):
"""
Save vtkImageData to XML file.
:param handle: file name
:param image_data: source
:type handle: str
:type image_data: :py:class:`vtk.vtkImageData`
>>> image_data = create_image_data(32, 32, 32)
>>> save_image_data('test.vit', image_data)
"""
stub, ext = os.path.splitext(handle)
handle = stub + '.vti'
writer = vtk.vtkXMLImageDataWriter()
writer.SetInput(image_data)
writer.SetFileName(handle)
writer.Write()
开发者ID:JoshuaSBrown,项目名称:langmuir,代码行数:19,代码来源:vtkutils.py
示例18: getWriter
def getWriter(self,polyData):
writer = None;
if self.destFormat == "vti":
writer = vtk.vtkXMLImageDataWriter();
writer.SetFileName(self.dest);
elif self.destFormat in ("mha","mhd","raw"):
writer = vtk.vtkMetaImageWriter();
writer.SetFilePrefix(self.dest);
writer.SetFileName(self.dest);
elif self.destFormat == "mnc":
writer = vtk.vtkMINCImageWriter();
writer.SetFileName(self.dest);
writer.StrictValidationOff();
elif self.destFormat == "vtk":
writer = vtk.vtkUnstructuredGridWriter();
writer.SetFileName(self.dest);
writer.SetInputData(polyData);
writer.Update();
return writer;
开发者ID:avontd2868,项目名称:OU_Final_Year,代码行数:19,代码来源:vtkIO.py
示例19: WriteToFile
def WriteToFile(self, imageData, exportFileName, fileType):
if fileType == DataReader.TypeMHD:
if not exportFileName.endswith(".mhd"):
exportFileName = exportFileName + ".mhd"
writer = vtkMetaImageWriter()
writer.SetFileName(exportFileName)
writer.SetInputData(imageData)
writer.Write()
elif fileType == DataReader.TypeVTI:
writer = vtkXMLImageDataWriter()
writer.SetFileName(exportFileName)
writer.SetInputData(imageData)
writer.Write()
elif fileType == DataReader.TypeMHA:
writer = vtkMetaImageWriter()
writer.SetFileName(exportFileName)
writer.SetInputData(imageData)
writer.Write()
else:
raise NotImplementedError("No writing support for type " + str(fileType))
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:20,代码来源:DataWriter.py
示例20: write_file
def write_file(self):
"""Writes all VTK grids in self.grid to VTI files"""
for key, value in self.grid.iteritems():
# creates directory for each term in Eclipse project directory
# root for all VTI files is dated by parser runtime date
dir_name = path.join(self.dir, time.strftime("%d_%m_%Y"))
dir_name = path.join(dir_name, key)
try:
makedirs(dir_name)
except OSError:
pass
i = 1
for each in tqdm(value, "Writing "+key+" vtk files"):
legacy = vtkXMLImageDataWriter()
legacy.SetFileName(path.join(dir_name, key + str(i) + '.vti'))
legacy.SetInputData(each)
legacy.Write()
i += 1
开发者ID:crappyoats,项目名称:eclipse_vision,代码行数:21,代码来源:VTKWriter.py
注:本文中的vtk.vtkXMLImageDataWriter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论