本文整理汇总了Python中vtk.vtkPiecewiseFunction函数的典型用法代码示例。如果您正苦于以下问题:Python vtkPiecewiseFunction函数的具体用法?Python vtkPiecewiseFunction怎么用?Python vtkPiecewiseFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkPiecewiseFunction函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: vtkKWVolumePropertyWidgetEntryPoint
def vtkKWVolumePropertyWidgetEntryPoint(parent, win):
app = parent.GetApplication()
# -----------------------------------------------------------------------
# This is a faily big widget, so create a scrolled frame
vpw_frame = vtkKWFrameWithScrollbar()
vpw_frame.SetParent(parent)
vpw_frame.Create()
app.Script("pack %s -side top -fill both -expand y", vpw_frame.GetWidgetName())
# -----------------------------------------------------------------------
# Create a volume property widget
vpw = vtkKWVolumePropertyWidget()
vpw.SetParent(vpw_frame.GetFrame())
vpw.Create()
app.Script("pack %s -side top -anchor nw -expand y -padx 2 -pady 2", vpw.GetWidgetName())
# Create a volume property and assign it
# We need color tfuncs, opacity, and gradient
vpw_vp = vtkVolumeProperty()
vpw_vp.SetIndependentComponents(1)
vpw_cfun = vtkColorTransferFunction()
vpw_cfun.SetColorSpaceToHSV()
vpw_cfun.AddHSVSegment(0.0, 0.2, 1.0, 1.0, 255.0, 0.8, 1.0, 1.0)
vpw_cfun.AddHSVSegment(80, 0.8, 1.0, 1.0, 130.0, 0.1, 1.0, 1.0)
vpw_ofun = vtkPiecewiseFunction()
vpw_ofun.AddSegment(0.0, 0.2, 255.0, 0.8)
vpw_ofun.AddSegment(40, 0.9, 120.0, 0.1)
vpw_gfun = vtkPiecewiseFunction()
vpw_gfun.AddSegment(0.0, 0.2, 60.0, 0.4)
vpw_vp.SetColor(0, vpw_cfun)
vpw_vp.SetScalarOpacity(0, vpw_ofun)
vpw_vp.SetGradientOpacity(0, vpw_gfun)
vpw.SetVolumeProperty(vpw_vp)
vpw.SetWindowLevel(128, 128)
# vpw.MergeScalarOpacityAndColorEditors()
return "TypeVTK"
开发者ID:FNNDSC,项目名称:KWWidgets,代码行数:52,代码来源:vtkKWVolumePropertyWidget.py
示例2: save_vtk_image
def save_vtk_image(images, dst, i):
image_import = vtk.vtkImageImport()
image_import.CopyImportVoidPointer(images.tostring(), len(images.tostring()))
image_import.SetDataScalarTypeToUnsignedChar()
image_import.SetNumberOfScalarComponents(1)
image_import.SetDataExtent(0, images.shape[2] - 1, 0, images.shape[1] - 1, 0, images.shape[0] - 1)
image_import.SetWholeExtent(0, images.shape[2] - 1, 0, images.shape[1] - 1, 0, images.shape[0] - 1)
volume = vtk.vtkVolume()
volume_mapper = vtk.vtkVolumeRayCastMapper()
alpha_channel_func = vtk.vtkPiecewiseFunction()
alpha_channel_func.AddPoint(0, 0.0)
# alpha_channel_func.AddPoint(64, 0.3)
# alpha_channel_func.AddPoint(128, 0.5)
alpha_channel_func.AddPoint(100, 1.0)
alpha_channel_func.ClampingOn()
color_func = vtk.vtkPiecewiseFunction()
color_func.AddPoint(5, 0.3)
color_func.AddPoint(25, 0.5)
color_func.AddPoint(125, 0.7)
color_func.AddPoint(255, 1.0)
volume_property = vtk.vtkVolumeProperty()
volume_property.SetColor(color_func)
volume_property.SetInterpolationTypeToLinear()
volume_property.SetScalarOpacity(alpha_channel_func)
volume.SetProperty(volume_property)
volume_ray_cast_func = vtk.vtkVolumeRayCastMIPFunction()
volume_mapper.SetInputConnection(image_import.GetOutputPort())
volume_mapper.SetVolumeRayCastFunction(volume_ray_cast_func)
# volume_mapper.SetSampleDistance(1)
# volume_mapper.SetAutoAdjustSampleDistances(0)
# volume_mapper.SetImageSampleDistance(1)
volume.SetMapper(volume_mapper)
ren = vtk.vtkRenderer()
ren.AddVolume(volume)
ren.SetBackground(0, 0, 0)
renWin = vtk.vtkRenderWindow()
renWin.SetSize(1024, 1024)
renWin.AddRenderer(ren)
renWin.Render()
window_2_image = vtk.vtkWindowToImageFilter()
window_2_image.SetInput(renWin)
window_2_image.Update()
png_writer = vtk.vtkPNGWriter()
png_writer.SetFileName(dst + '%05d'%(i) + '.png')
png_writer.SetInput(window_2_image.GetOutput())
png_writer.Write()
开发者ID:sulei1324,项目名称:lab_codes,代码行数:49,代码来源:funs.py
示例3: default_opacity_transfer_function
def default_opacity_transfer_function(x1, x2):
maxs = max(x1, x2)
mins = min(x1, x2)
opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(mins, 0.0)
opacityTransferFunction.AddPoint(maxs, 0.2)
return opacityTransferFunction
开发者ID:sldion,项目名称:DNACC,代码行数:7,代码来源:Volume.py
示例4: __init__
def __init__(self, img, color):
self.volume = vtk.vtkVolume()
self.__color = color
dataImporter = vtk.vtkImageImport()
simg = np.ascontiguousarray(img, np.uint8)
dataImporter.CopyImportVoidPointer(simg.data, len(simg.data))
dataImporter.SetDataScalarTypeToUnsignedChar()
dataImporter.SetNumberOfScalarComponents(1)
dataImporter.SetDataExtent(0, simg.shape[2]-1, 0, simg.shape[1]-1, 0, simg.shape[0]-1)
dataImporter.SetWholeExtent(0, simg.shape[2]-1, 0, simg.shape[1]-1, 0, simg.shape[0]-1)
self.__smoother = vtk.vtkImageGaussianSmooth()
self.__smoother.SetStandardDeviation(1, 1, 1)
self.__smoother.SetInputConnection(dataImporter.GetOutputPort())
volumeMapper = vtk.vtkSmartVolumeMapper()
volumeMapper.SetInputConnection(self.__smoother.GetOutputPort())
self.__volumeProperty = vtk.vtkVolumeProperty()
self.__colorFunc = vtk.vtkColorTransferFunction()
self.__alpha = vtk.vtkPiecewiseFunction()
for i in range(256):
self.__colorFunc.AddRGBPoint(i, i * color[0], i * color[1], i * color[2])
self.__alpha.AddPoint(5, .01)
self.__alpha.AddPoint(10, .03)
self.__alpha.AddPoint(50, .1)
self.__alpha.AddPoint(150, .2)
self.__volumeProperty.SetColor(self.__colorFunc)
self.__volumeProperty.SetScalarOpacity(self.__alpha)
self.volume.SetMapper(volumeMapper)
self.volume.SetProperty(self.__volumeProperty)
开发者ID:LeeKamentsky,项目名称:q3dstack,代码行数:28,代码来源:q3dstack.py
示例5: __init__
def __init__(self, name, image_data):
if not isinstance(image_data, vtk.vtkImageData):
raise TypeError("input has to be vtkImageData")
self.name = name
# Create transfer mapping scalar value to opacity.
opacity_function = vtk.vtkPiecewiseFunction()
opacity_function.AddPoint(0, 0.0)
opacity_function.AddPoint(127, 0.0)
opacity_function.AddPoint(128, 0.2)
opacity_function.AddPoint(255, 0.2)
# Create transfer mapping scalar value to color.
color_function = vtk.vtkColorTransferFunction()
color_function.SetColorSpaceToHSV()
color_function.AddHSVPoint(0, 0.0, 0.0, 0.0)
color_function.AddHSVPoint(127, 0.0, 0.0, 0.0)
color_function.AddHSVPoint(128, 0.0, 0.0, 1.0)
color_function.AddHSVPoint(255, 0.0, 0.0, 1.0)
volume_property = vtk.vtkVolumeProperty()
volume_property.SetColor(color_function)
volume_property.SetScalarOpacity(opacity_function)
volume_property.ShadeOn()
volume_property.SetInterpolationTypeToLinear()
volume_mapper = vtk.vtkSmartVolumeMapper()
volume_mapper.SetInputData(image_data)
self.volume = vtk.vtkVolume()
self.volume.SetMapper(volume_mapper)
self.volume.SetProperty(volume_property)
开发者ID:papazov3d,项目名称:invipy,代码行数:33,代码来源:vtkvol.py
示例6: originalObject
def originalObject(self):
pieceWiseFunction = vtkPiecewiseFunction()
for index in range(len(self.nodes)):
value = self.nodes[index]
pieceWiseFunction.AddPoint(value[0], value[1], value[2], value[3])
return pieceWiseFunction
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:7,代码来源:vtkObjectWrapper.py
示例7: alpha_fn
def alpha_fn(deactivated):
fn = vtk.vtkPiecewiseFunction()
fn.AddPoint(0, 0)
for i in range(1, 16):
fn.AddPoint(i, 0.0 if i - 1 in deactivated else 0.3)
fn.AddPoint(16, 0)
return fn
开发者ID:chielk,项目名称:beautiful_data,代码行数:7,代码来源:frog.py
示例8: _createPipeline
def _createPipeline(self):
# setup our pipeline
self._splatMapper = vtkdevide.vtkOpenGLVolumeShellSplatMapper()
self._splatMapper.SetOmegaL(0.9)
self._splatMapper.SetOmegaH(0.9)
# high-quality rendermode
self._splatMapper.SetRenderMode(0)
self._otf = vtk.vtkPiecewiseFunction()
self._otf.AddPoint(0.0, 0.0)
self._otf.AddPoint(0.9, 0.0)
self._otf.AddPoint(1.0, 1.0)
self._ctf = vtk.vtkColorTransferFunction()
self._ctf.AddRGBPoint(0.0, 0.0, 0.0, 0.0)
self._ctf.AddRGBPoint(0.9, 0.0, 0.0, 0.0)
self._ctf.AddRGBPoint(1.0, 1.0, 0.937, 0.859)
self._volumeProperty = vtk.vtkVolumeProperty()
self._volumeProperty.SetScalarOpacity(self._otf)
self._volumeProperty.SetColor(self._ctf)
self._volumeProperty.ShadeOn()
self._volumeProperty.SetAmbient(0.1)
self._volumeProperty.SetDiffuse(0.7)
self._volumeProperty.SetSpecular(0.2)
self._volumeProperty.SetSpecularPower(10)
self._volume = vtk.vtkVolume()
self._volume.SetProperty(self._volumeProperty)
self._volume.SetMapper(self._splatMapper)
开发者ID:fvpolpeta,项目名称:devide,代码行数:30,代码来源:shellSplatSimple.py
示例9: create_volume_rendering
def create_volume_rendering(self):
opacityfunction=vtk.vtkPiecewiseFunction()
opacityfunction.AddPoint(0,0.0)
opacityfunction.AddPoint(0.1,0.01)
opacityfunction.AddPoint(1,0.02)
opacityfunction.AddPoint(1.5,0.03)
volproperty=vtk.vtkVolumeProperty()
volproperty.SetColor(self.arrowColor)
volproperty.SetScalarOpacity(opacityfunction)
volproperty.ShadeOn()
volproperty.SetInterpolationTypeToLinear()
volumeMapper = vtk.vtkGPUVolumeRayCastMapper()
volumeMapper.SetInputConnection(self.vol_reader.GetOutputPort())
volumeMapper.SetSampleDistance(0.01)
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volproperty)
return volume
开发者ID:svelezsaffon,项目名称:Diffusion_Tensor_Visualization_VTK,代码行数:25,代码来源:fa_hyper.py
示例10: volumeRender
def volumeRender(reader,ren,renWin):
#Create transfer mapping scalar value to opacity
opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(1, 0.0)
opacityTransferFunction.AddPoint(100, 0.1)
opacityTransferFunction.AddPoint(255,1.0)
colorTransferFunction = vtk.vtkColorTransferFunction()
colorTransferFunction.AddRGBPoint(0.0,0.0,0.0,0.0)
colorTransferFunction.AddRGBPoint(64.0,1.0,0.0,0.0)
colorTransferFunction.AddRGBPoint(128.0,0.0,0.0,1.0)
colorTransferFunction.AddRGBPoint(192.0,0.0,1.0,0.0)
colorTransferFunction.AddRGBPoint(255.0,0.0,0.2,0.0)
volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(colorTransferFunction)
volumeProperty.SetScalarOpacity(opacityTransferFunction)
volumeProperty.ShadeOn()
volumeProperty.SetInterpolationTypeToLinear()
compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
volumeMapper.SetInputConnection(reader.GetOutputPort())
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)
ren.RemoveAllViewProps()
ren.AddVolume(volume)
ren.SetBackground(1,1,1)
renWin.Render()
开发者ID:kvkenyon,项目名称:projects,代码行数:34,代码来源:App.py
示例11: updateTransferFunction
def updateTransferFunction(self):
r, g, b = self.color
# Transfer functions and properties
if not self.colorFunction:
self.colorFunction = vtkColorTransferFunction()
else:
self.colorFunction.RemoveAllPoints()
self.colorFunction.AddRGBPoint(self.minimum, r*0.7, g*0.7, b*0.7)
self.colorFunction.AddRGBPoint(self.maximum, r, g, b)
if not self.opacityFunction:
self.opacityFunction = vtkPiecewiseFunction()
else:
self.opacityFunction.RemoveAllPoints()
self.opacityFunction.AddPoint(self.minimum, 0)
self.opacityFunction.AddPoint(self.lowerBound, 0)
self.opacityFunction.AddPoint(self.lowerBound+0.0001, self.opacity)
self.opacityFunction.AddPoint(self.upperBound-0.0001, self.opacity)
self.opacityFunction.AddPoint(self.upperBound, 0)
self.opacityFunction.AddPoint(self.maximum+0.0001, 0)
self.volProp.SetColor(self.colorFunction)
self.volProp.SetScalarOpacity(self.opacityFunction)
self.updatedTransferFunction.emit()
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:26,代码来源:VolumeVisualizationSimple.py
示例12: _create_pipeline
def _create_pipeline(self):
# setup our pipeline
self._otf = vtk.vtkPiecewiseFunction()
self._ctf = vtk.vtkColorTransferFunction()
self._volume_property = vtk.vtkVolumeProperty()
self._volume_property.SetScalarOpacity(self._otf)
self._volume_property.SetColor(self._ctf)
self._volume_property.ShadeOn()
self._volume_property.SetAmbient(0.1)
self._volume_property.SetDiffuse(0.7)
self._volume_property.SetSpecular(0.2)
self._volume_property.SetSpecularPower(10)
self._volume_raycast_function = vtk.vtkVolumeRayCastMIPFunction()
self._volume_mapper = vtk.vtkVolumeRayCastMapper()
# can also used FixedPoint, but then we have to use:
# SetBlendModeToMaximumIntensity() and not SetVolumeRayCastFunction
#self._volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()
self._volume_mapper.SetVolumeRayCastFunction(
self._volume_raycast_function)
module_utils.setup_vtk_object_progress(self, self._volume_mapper,
'Preparing render.')
self._volume = vtk.vtkVolume()
self._volume.SetProperty(self._volume_property)
self._volume.SetMapper(self._volume_mapper)
开发者ID:fvpolpeta,项目名称:devide,代码行数:32,代码来源:MIPRender.py
示例13: __init__
def __init__(self, module_manager):
ModuleBase.__init__(self, module_manager)
self._volume_input = None
self._opacity_tf = vtk.vtkPiecewiseFunction()
self._colour_tf = vtk.vtkColorTransferFunction()
self._lut = vtk.vtkLookupTable()
# list of tuples, where each tuple (scalar_value, (r,g,b,a))
self._config.transfer_function = [
(0, (0,0,0), 0),
(255, (255,255,255), 1)
]
self._view_frame = None
self._create_view_frame()
self._bind_events()
self.view()
# all modules should toggle this once they have shown their
# stuff.
self.view_initialised = True
self.config_to_logic()
self.logic_to_config()
self.config_to_view()
开发者ID:fvpolpeta,项目名称:devide,代码行数:28,代码来源:TransferFunctionEditor.py
示例14: volumeRender
def volumeRender(img, tf=[],spacing=[1.0,1.0,1.0]):
importer = numpy2VTK(img,spacing)
# Transfer Functions
opacity_tf = vtk.vtkPiecewiseFunction()
color_tf = vtk.vtkColorTransferFunction()
if len(tf) == 0:
tf.append([img.min(),0,0,0,0])
tf.append([img.max(),1,1,1,1])
for p in tf:
color_tf.AddRGBPoint(p[0], p[1], p[2], p[3])
opacity_tf.AddPoint(p[0], p[4])
volMapper = vtk.vtkGPUVolumeRayCastMapper()
volMapper.SetInputConnection(importer.GetOutputPort())
# The property describes how the data will look
volProperty = vtk.vtkVolumeProperty()
volProperty.SetColor(color_tf)
volProperty.SetScalarOpacity(opacity_tf)
volProperty.ShadeOn()
volProperty.SetInterpolationTypeToLinear()
vol = vtk.vtkVolume()
vol.SetMapper(volMapper)
vol.SetProperty(volProperty)
return [vol]
开发者ID:zadacka,项目名称:MSC_Project,代码行数:30,代码来源:kevin_numpy_converter.py
示例15: createSkinOTF
def createSkinOTF(tissues):
skinOTF = vtk.vtkPiecewiseFunction()
skinOTF.AddPoint(70, 0)
skinOTF.AddPoint(80, tissues[15].opacity *.5)
skinOTF.AddPoint(90, tissues[15].opacity *.5)
skinOTF.AddPoint(100.0, 0)
return skinOTF
开发者ID:JaroCamphuijsen,项目名称:SVVR,代码行数:7,代码来源:Assignment4.py
示例16: createOTF
def createOTF(tissues):
OTF = vtk.vtkPiecewiseFunction()
OTF.AddPoint(0, 0)
for t in tissues:
OTF.AddPoint(t.val - 0.5, 0)
OTF.AddPoint(t.val, t.opacity)
OTF.AddPoint(t.val + 0.5, 0)
OTF.AddPoint(17.0, 0)
return OTF
开发者ID:JaroCamphuijsen,项目名称:SVVR,代码行数:9,代码来源:Assignment4.py
示例17: createOpacityTransferFunction
def createOpacityTransferFunction(values):
opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(1.0, 0)
for v in values:
opacityTransferFunction.AddPoint(v - 0.01, 0)
opacityTransferFunction.AddPoint(v, 0.2)
opacityTransferFunction.AddPoint(v + 0.01, 0)
opacityTransferFunction.AddPoint(17.0, 0)
return opacityTransferFunction
开发者ID:JaroCamphuijsen,项目名称:SVVR,代码行数:9,代码来源:Assignment4_old.py
示例18: get_vtk_transfer_functions
def get_vtk_transfer_functions(self):
of = vtk.vtkPiecewiseFunction()
cf = vtk.vtkColorTransferFunction()
for pt in self._pts:
(scalar, opacity, color) = pt
# Map scalar to tf range
s = self._min_range + (self._max_range - self._min_range) * scalar
of.AddPoint(s, opacity)
cf.AddRGBPoint(s, color[0], color[1], color[2])
return (of,cf)
开发者ID:cjh1,项目名称:VisTrails,代码行数:10,代码来源:tf_widget.py
示例19: getTFxn
def getTFxn(self):
a = self.alphaFxn.get_function ()
f = vtk.vtkPiecewiseFunction ()
npnt = self.alphaFxn.npoints
dt = 1.0/(npnt - 1.0)
ds = (self.max_x - self.min_x)/(npnt - 1.0)
for i in range(npnt):
f.AddPoint(self.min_x + i*ds, a.GetValue(i*dt))
return f
开发者ID:sldion,项目名称:DNACC,代码行数:10,代码来源:CTFEditor.py
示例20: setDataUnit
def setDataUnit(self, dataunit):
"""
Sets the dataunit this module uses for visualization
"""
Logging.info("Dataunit for Volume Rendering:", dataunit, kw = "rendering")
VisualizationModule.setDataUnit(self, dataunit)
otf, otf2 = vtk.vtkPiecewiseFunction(), vtk.vtkPiecewiseFunction()
d = dataunit.getSingleComponentBitDepth()
maxv = 2 ** d
otf2.AddPoint(0, 0.0)
otf2.AddPoint(maxv, 1.0)
otf.AddPoint(0, 0.0)
otf.AddPoint(maxv, 0.2)
self.otfs = [otf, otf, otf, otf2, otf]
self.setInputChannel(1, 0)
self.parameters["Palette"] = self.colorTransferFunction
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:20,代码来源:Volume.py
注:本文中的vtk.vtkPiecewiseFunction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论