本文整理汇总了Python中vtk.vtkImageReslice函数的典型用法代码示例。如果您正苦于以下问题:Python vtkImageReslice函数的具体用法?Python vtkImageReslice怎么用?Python vtkImageReslice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkImageReslice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: GetROIImage
def GetROIImage(self, clipDataOn=0):
"""Return ROI Image port from ROIStencil"""
component.getUtility(ICurrentImage).Update()
minV, maxV = component.getUtility(ICurrentImage).GetScalarRange()
reslice = vtk.vtkImageReslice()
reslice.SetInputConnection(
component.getUtility(ICurrentImage).GetOutputPort())
reslice.SetInterpolationModeToCubic()
# 2014-12-22 this is important
self.__stencil_data.Update()
# VTK-6
if vtk.vtkVersion().GetVTKMajorVersion() > 5:
reslice.SetStencilData(self.__stencil_data)
else:
reslice.SetStencil(self.__stencil_data)
reslice.SetOutputExtent(self.__stencil_data.GetWholeExtent())
reslice.SetOutputOrigin(self._Origin)
reslice.SetOutputSpacing(self._Spacing)
reslice.SetBackgroundLevel(minV)
reslice.Update()
return reslice
开发者ID:andyTsing,项目名称:MicroView,代码行数:25,代码来源:BasicBoneAnalysis.py
示例2: __init__
def __init__(
self, parent=None, x=0, y=0, width=100, height=27, fontsize=_FS,
**kw):
kw["height"] = height
kw["width"] = width
kw["x"] = x
kw["y"] = y
kw["fontsize"] = fontsize
kw["font"] = "courier"
kw["text"] = "0.000"
Label.__init__(*(self, parent), **kw)
self._Cursor = None
self._Transform = None
self._Shift = 0.0
self._Scale = 1.0
self._Input = None
self._Reslice = vtk.vtkImageReslice()
self._Reslice.SetOutputExtent(0, 0, 0, 0, 0, 0)
self._Reslice.SetInterpolationModeToLinear()
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:27,代码来源:IntensityLabel.py
示例3: vtkZoomImage
def vtkZoomImage(image, zoomInFactor):
"""
Zoom a volume
"""
zoomOutFactor = 1.0 / zoomInFactor
reslice = vtk.vtkImageReslice()
reslice.SetInputConnection(image.GetProducerPort())
spacing = image.GetSpacing()
extent = image.GetExtent()
origin = image.GetOrigin()
extent = (extent[0], extent[1] / zoomOutFactor, extent[2], extent[3] / zoomOutFactor, extent[4], extent[5])
spacing = (spacing[0] * zoomOutFactor, spacing[1] * zoomOutFactor, spacing[2])
reslice.SetOutputSpacing(spacing)
reslice.SetOutputExtent(extent)
reslice.SetOutputOrigin(origin)
# These interpolation settings were found to have the
# best effect:
# If we zoom out, no interpolation
if zoomOutFactor > 1:
reslice.InterpolateOff()
else:
# If we zoom in, use cubic interpolation
reslice.SetInterpolationModeToCubic()
reslice.InterpolateOn()
data = optimize.execute_limited(reslice)
data.Update()
return data
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:30,代码来源:ImageOperations.py
示例4: __init__
def __init__(self):
self.__vtkimport=vtk.vtkImageImport()
self.__vtkimport.SetDataScalarTypeToFloat()
self.__vtkimport.SetNumberOfScalarComponents(1)
self.__filePattern=self.__defaultFilePattern
self.__data = None
self._irs = vtk.vtkImageReslice()
开发者ID:neurodebian,项目名称:PyLocator,代码行数:7,代码来源:vtkNifti.py
示例5: __init__
def __init__(self,data_reader,origin,normal,camera_normal):
self.axial=self.get_matrix(data_reader,origin,normal,camera_normal)
# Extract a slice in the desired orientation
self.reslice = vtk.vtkImageReslice()
self.reslice.SetInput(data_reader.get_data_set())
self.reslice.SetOutputDimensionality(2)
self.reslice.SetResliceAxes(self.axial)
self.reslice.SetInterpolationModeToLinear()
self.contour=vtk.vtkContourFilter()
self.contour.SetInputConnection(self.reslice.GetOutputPort())
self.contour.GenerateValues(25, data_reader.get_scalar_range())
self.contour.ComputeScalarsOn()
self.contour.ComputeGradientsOn()
self.cutmapper=vtk.vtkPolyDataMapper()
self.cutmapper.SetInputConnection(self.contour.GetOutputPort())
self.actor=vtk.vtkActor()
self.actor.SetMapper(self.cutmapper)
self.actor.PokeMatrix(self.axial)
c="c"
if origin[0]==c or origin[1]==c or origin[2]==c:
origin=self.center
origin=(float(origin[0]),float(origin[1]),float(origin[2]))
self.actor.SetOrigin(origin)
开发者ID:bitcoinsoftware,项目名称:3D-Scientific-Visualization,代码行数:26,代码来源:Contour.py
示例6: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkImageReslice(), 'Processing.',
('vtkImageData', 'vtkImageStencilData'), ('vtkImageData',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkImageReslice.py
示例7: __init__
def __init__(self, ren):
self.volume = self.LoadVolume()
self.ren = ren
# next initialize the pipeline
self.slicer = vtk.vtkImageReslice()
self.slicer.SetInput( self.volume )
self.slicer.SetOutputDimensionality(2)
# the next filter provides a mechanism for slice selection
self.selector = SliceSelector(self.volume)
self.slicer.SetResliceAxes( self.selector.GetDirectionCosines() )
self.slicer.SetResliceAxesOrigin( self.selector.GetAxesOrigin() )
# setup link for adjusting the contrast of the image
r = self.volume.GetScalarRange()
self.lutBuilder = LUTBuilder(r[0],r[1],1)
lut = self.lutBuilder.Build()
self.colors = vtk.vtkImageMapToColors()
self.colors.SetInputConnection( self.slicer.GetOutputPort() )
self.colors.SetLookupTable( lut )
self.actor = vtk.vtkImageActor()
self.actor.SetInput( self.colors.GetOutput() )
开发者ID:ewong718,项目名称:freesurfer,代码行数:25,代码来源:ImagePipeline.py
示例8: __init__
def __init__(self, module_manager):
# initialise our base class
ModuleBase.__init__(self, module_manager)
# initialise any mixins we might have
NoConfigModuleMixin.__init__(self)
self._imageReslice = vtk.vtkImageReslice()
self._imageReslice.SetInterpolationModeToCubic()
self._matrixToHT = vtk.vtkMatrixToHomogeneousTransform()
self._matrixToHT.Inverse()
module_utils.setup_vtk_object_progress(self, self._imageReslice,
'Resampling volume')
self._viewFrame = self._createViewFrame(
{'Module (self)' : self,
'vtkImageReslice' : self._imageReslice})
# pass the data down to the underlying logic
self.config_to_logic()
# and all the way up from logic -> config -> view to make sure
self.syncViewWithLogic()
开发者ID:fvpolpeta,项目名称:devide,代码行数:25,代码来源:testModule2.py
示例9: __init__
def __init__(self, module_manager):
# initialise our base class
ModuleBase.__init__(self, module_manager)
self._reslicer = vtk.vtkImageReslice()
self._probefilter = vtk.vtkProbeFilter()
self._config.paddingValue = 0.0
#This is retarded - we (sometimes, see below) need the padder
#to get the image extent big enough to satisfy the probe filter.
#No apparent logical reason, but it throws an exception if we don't.
self._padder = vtk.vtkImageConstantPad()
configList = [
('Padding value:', 'paddingValue', 'base:float', 'text',
'The value used to pad regions that are outside the supplied volume.')]
# initialise any mixins we might have
ScriptedConfigModuleMixin.__init__(
self, configList,
{'Module (self)': self,
'vtkImageReslice': self._reslicer,
'vtkProbeFilter': self._probefilter,
'vtkImageConstantPad': self._padder})
module_utils.setup_vtk_object_progress(self, self._reslicer,
'Transforming image (Image Reslice)')
module_utils.setup_vtk_object_progress(self, self._probefilter,
'Performing remapping (Probe Filter)')
self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:32,代码来源:transformImageToTarget.py
示例10: 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
示例11: transform_all_images
def transform_all_images(register, image_datas, defining_image):
image_list = list()
idx = 0
transform_list = register.convert_transforms_to_vtk()
image_datas = [image_datas[0]]
info = vtk.vtkImageChangeInformation()
info.SetInput(defining_image)
info.CenterImageOn()
for image in image_datas:
change = vtk.vtkImageChangeInformation()
change.SetInput(image)
change.CenterImageOn()
#change.SetOutputSpacing(1,1,1)
#spacing = image.GetSpacing()
if 1:
trans = vtk.vtkTransform()
# this is right except scaling is 1/correct
tx = transform_list[idx]
trans.Concatenate(tx)
#trans = tx
#trans.Scale(-1,-1,-1)
trans.Inverse()
#trans.Scale(-1,-1,-1)
if 0:
transform = numpy.zeros(15)
transform2 = numpy.zeros(15)
tform = register._subjects[idx].transform
# rotation and translation are "already inverted"
# from images being in LPS
transform[0:6] = tform[0:6]
# invert scaling
transform[6:9] = numpy.divide(1.0, tform[6:9])
# invert shear
transform2[6:9] = 1.0
transform2[9:15] = tform[9:15]
reg_ops = wma.register.RegistrationInformation()
trans = reg_ops.convert_transform_to_vtk(transform)
trans2 = reg_ops.convert_transform_to_vtk(transform2)
trans2.Scale(-1,-1,-1)
trans2.Inverse()
trans.Concatenate(trans2)
resample = vtk.vtkImageReslice()
#resample.SetResliceAxesDirectionCosines(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
#resample.SetResliceAxesDirectionCosines(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0)
#resample.SetInput(image)
resample.SetInput(change.GetOutput())
resample.SetResliceTransform(trans)
print trans
#resample.SetInformationInput(info.GetOutput())
#resample.SetOutputSpacing(spacing)
resample.Update()
#resample.SetOutputOrigin(origin)
image_list.append(resample.GetOutput())
idx += 1
del resample
return image_list
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:59,代码来源:test_read_vol.py
示例12: __init__
def __init__(self, module_manager):
# initialise our base class
ModuleBase.__init__(self, module_manager)
NoConfigModuleMixin.__init__(
self, {'Module (self)' : self})
self.sync_module_logic_with_config()
self._ir = vtk.vtkImageReslice()
self._ici = vtk.vtkImageChangeInformation()
开发者ID:fvpolpeta,项目名称:devide,代码行数:10,代码来源:DICOMAligner.py
示例13: __init__
def __init__(self):
# index
self.ori_index = [0,0,0]
self.ori_direction = [1,1,1] #cosine
self.cur_index = [0,0,0]
self.cur_direction = [1,1,1] #cosine
#define reslice fileter
self.reslicer = vtk.vtkImageReslice()
self.reslicer.SetOutputDimensionality(2) #output 2D resliced image
self.reslicer.SetResliceAxesDirectionCosines([0,0,0,0,0,0,0,0,0])#(self.cur_direction[1],self.cur_direction[1],self.cur_direction[1])
self.reslicer.SetResliceAxesOrigin(0,0,0)#(self.cur_index)
self.reslicer.SetInterpolationModeToLinear()
开发者ID:Beastmaster,项目名称:itk-python-example,代码行数:12,代码来源:vtkLayeredRenderers.py
示例14: reslice
def reslice(img, transform, data):
reslicer=vtk.vtkImageReslice()
reslicer.SetInputData(img)
transform = numpy2vtkMatrix(transform)
vtkTrans = vtk.vtkMatrixToHomogeneousTransform()
vtkTrans.SetInput(transform)
reslicer.SetResliceTransform(vtkTrans)
reslicer.SetOutputOrigin(data.GetOrigin())
reslicer.SetOutputSpacing(data.GetSpacing())
reslicer.SetOutputExtent(data.GetExtent())
开发者ID:deherinu,项目名称:TmsViewer,代码行数:13,代码来源:transform.py
示例15: SetImageTransform
def SetImageTransform(self, transform):
"""Set optionally the transform to the image data."""
# TODO: this code is broken...
self._imageTransform = transform
reslice = vtk.vtkImageReslice()
reslice.SetInterpolationModeToCubic()
image = component.getUtility(ICurrentImage)
reslice.SetInputConnection(image.GetOutputPort())
reslice.SetResliceTransform(self._imageTransform.GetInverse())
self._imageStats.SetInputConnection(reslice.GetOutputPort())
self._imageStats.SetProgressText("Calculating image stats...")
开发者ID:andyTsing,项目名称:MicroView,代码行数:13,代码来源:ROIStatistics.py
示例16: FixGantryTilt
def FixGantryTilt(imagedata, tilt):
"""
Fix gantry tilt given a vtkImageData and the tilt value. Return new
vtkImageData.
"""
# Retrieve data from original imagedata
extent = [int(value) for value in imagedata.GetExtent()]
origin = imagedata.GetOrigin()
spacing = [float(value) for value in imagedata.GetSpacing()]
n_slices = int(extent[5])
new_zspacing = math.cos(tilt*(math.acos(-1.0)/180.0)) * spacing[2] #zspacing
translate_coef = math.tan(tilt*math.pi/180.0)*new_zspacing*(n_slices-1)
# Class responsible for translating data
reslice = vtk.vtkImageReslice()
reslice.SetInput(imagedata)
reslice.SetInterpolationModeToLinear()
# Translation will create new pixels. Let's set new pixels' colour to black.
reslice.SetBackgroundLevel(imagedata.GetScalarRange()[0])
# Class responsible for append translated data
append = vtk.vtkImageAppend()
append.SetAppendAxis(2)
# Translate and append each slice
for i in xrange(n_slices+1):
slice_imagedata = vtk.vtkImageData()
value = math.tan(tilt*math.pi/180.0) * new_zspacing * i
new_origin1 = origin[1] + value - translate_coef
# Translate data
reslice.SetOutputOrigin(origin[0], new_origin1, origin[2])
reslice.SetOutputExtent(extent[0], extent[1], extent[2], extent[3], i,i)
reslice.Update()
# Append data
slice_imagedata.DeepCopy(reslice.GetOutput())
slice_imagedata.UpdateInformation()
append.AddInput(slice_imagedata)
append.Update()
# Final imagedata
imagedata = vtk.vtkImageData()
imagedata.DeepCopy(append.GetOutput())
imagedata.SetSpacing(spacing[0], spacing[1], new_zspacing)
imagedata.SetExtent(extent)
imagedata.UpdateInformation()
return imagedata
开发者ID:151706061,项目名称:invesalius,代码行数:51,代码来源:imagedata_utils.py
示例17: transform_all_images_lps_to_ras
def transform_all_images_lps_to_ras(image_datas):
image_list = list()
for image in image_datas:
resample = vtk.vtkImageReslice()
resample.SetResliceAxesDirectionCosines(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0)
resample.SetInput(image)
#resample.SetResliceTransform(trans)
#print trans
#resample.SetInformationInput(info.GetOutput())
resample.Update()
#resample.SetOutputOrigin(origin)
image_list.append(resample.GetOutput())
del resample
return image_list
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:14,代码来源:test_read_vol.py
示例18: scaleImage
def scaleImage(data, factor=1.0, zDimension=-1, interpolation=1, xfactor=0.0, yfactor=0.0):
"""
Scale an image with cubic interpolation
"""
if zDimension != -1:
data = getSlice(data, zDimension)
data.SetSpacing(1, 1, 1)
xDimension, yDimension, zDimension = data.GetDimensions()
data.SetOrigin(xDimension / 2.0, yDimension / 2.0, 0)
transform = vtk.vtkTransform()
xExtent0, xExtent1, yExtent0, yExtent1, zExtent0, zExtent1 = data.GetExtent()
if xfactor or yfactor:
xfactor *= factor
yfactor *= factor
if not (xfactor or yfactor):
transform.Scale(1 / factor, 1 / factor, 1)
else:
transform.Scale(1 / xfactor, 1 / yfactor, 1)
reslice = vtk.vtkImageReslice()
reslice.SetOutputOrigin(0, 0, 0)
reslice.SetInputConnection(data.GetProducerPort())
if not (xfactor or yfactor):
xfactor = factor
yfactor = factor
xSize = (xExtent1 - xExtent0 + 1) * xfactor
xExtent0 *= xfactor
xExtent1 = xExtent0 + xSize - 1
ySize = (yExtent1 - yExtent0 + 1) * yfactor
yExtent0 *= yfactor
yExtent1 = yExtent0 + ySize - 1
reslice.SetOutputExtent(int(xExtent0), int(xExtent1), int(yExtent0), int(yExtent1), zExtent0, zExtent1)
reslice.SetResliceTransform(transform)
if interpolation == 0:
reslice.SetInterpolationModeToNearestNeighbor()
if interpolation == 1:
reslice.SetInterpolationModeToLinear()
else:
reslice.SetInterpolationModeToCubic()
# XXX: modified, try to get errors out
data = reslice.GetOutput()
data.Update()
return data
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:50,代码来源:ImageOperations.py
示例19: __init__
def __init__(self, parent=None):
super(VtkFgBgDisplayWidget, self).__init__(parent)
self.imVtkBg = None
self.imVtkFg = None
self.matrix4x4 = vtk.vtkMatrix4x4()
self.matrix4x4.DeepCopy((
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
))
self.reslice = vtk.vtkImageReslice()
self.reslice.SetOutputDimensionality(3)
self.reslice.SetResliceAxes(self.matrix4x4)
self.reslice.SetInterpolationModeToLinear()
self.setupVtkRendering()
开发者ID:lirenzhucn,项目名称:ManualRegistrationTool,代码行数:16,代码来源:ManualRegistrationTool.py
示例20: gen_slice
def gen_slice(img, pnt=(30, 42, 57), wxyz=(30.0, 0.0, 0.0, 1.0), ext=get_xy_extent()):
""" generate the slice on xy plane"""
tf = vtk.vtkTransform()
tf.RotateWXYZ(wxyz[0], wxyz[1:4])
rs = vtk.vtkImageReslice()
rs.SetInputData(img)
rs.SetResliceTransform(tf)
rs.SetOutputExtent(ext)
rs.SetOutputOrigin(pnt)
rs.SetInterpolationModeToLinear()
rs.Update()
return rs
开发者ID:pengsun,项目名称:CatVSDog,代码行数:17,代码来源:dfm.py
注:本文中的vtk.vtkImageReslice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论