当前位置: 首页>>代码示例>>Python>>正文


Python visuals.Image方法代码示例

本文整理汇总了Python中vispy.scene.visuals.Image方法的典型用法代码示例。如果您正苦于以下问题:Python visuals.Image方法的具体用法?Python visuals.Image怎么用?Python visuals.Image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vispy.scene.visuals的用法示例。


在下文中一共展示了visuals.Image方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: image_visual

# 需要导入模块: from vispy.scene import visuals [as 别名]
# 或者: from vispy.scene.visuals import Image [as 别名]
def image_visual(image, parent=None):
    """
    Returns a :class:`vispy.scene.visuals.Image` class instance using given
    image.

    Parameters
    ----------
    image : array_like
        Image.
    parent : Node, optional
        Parent of the image visual in the `SceneGraph`.

    Returns
    -------
    Image
        Image visual.
    """

    image = np.clip(image, 0, 1)

    return Image(image, parent=parent) 
开发者ID:colour-science,项目名称:colour-analysis,代码行数:23,代码来源:image.py

示例2: __init__

# 需要导入模块: from vispy.scene import visuals [as 别名]
# 或者: from vispy.scene.visuals import Image [as 别名]
def __init__(self, layer):
        node = ImageNode(None, method='auto')
        super().__init__(layer, node)

        # Once #1842 and #1844 from vispy are released and gamma adjustment is
        # done on the GPU these can be dropped
        self._raw_cmap = None
        self._gamma = 1

        # Until we add a specific attenuation parameter to vispy we have to
        # track both iso_threshold and attenuation ourselves.
        self._iso_threshold = 1
        self._attenuation = 1

        self._on_display_change()
        self._on_slice_data_change() 
开发者ID:napari,项目名称:napari,代码行数:18,代码来源:vispy_image_layer.py

示例3: _on_display_change

# 需要导入模块: from vispy.scene import visuals [as 别名]
# 或者: from vispy.scene.visuals import Image [as 别名]
def _on_display_change(self, data=None):
        parent = self.node.parent
        self.node.parent = None

        if self.layer.dims.ndisplay == 2:
            self.node = ImageNode(data, method='auto')
        else:
            if data is None:
                data = np.zeros((1, 1, 1))
            self.node = VolumeNode(data, clim=self.layer.contrast_limits)

        self.node.parent = parent
        self.reset() 
开发者ID:napari,项目名称:napari,代码行数:15,代码来源:vispy_image_layer.py

示例4: reset

# 需要导入模块: from vispy.scene import visuals [as 别名]
# 或者: from vispy.scene.visuals import Image [as 别名]
def reset(self, event=None):
        self._reset_base()
        self._on_colormap_change(self.layer.colormap)
        self._on_rendering_change(self.layer.rendering)
        if isinstance(self.node, ImageNode):
            self._on_contrast_limits_change(self.layer.contrast_limits) 
开发者ID:napari,项目名称:napari,代码行数:8,代码来源:vispy_image_layer.py

示例5: _on_slice_data_change

# 需要导入模块: from vispy.scene import visuals [as 别名]
# 或者: from vispy.scene.visuals import Image [as 别名]
def _on_slice_data_change(self, event=None):
        # Slice data event will be fixed to use passed value after EVH refactor
        # is finished for all layers
        data = self.layer._data_view
        dtype = np.dtype(data.dtype)
        if dtype not in texture_dtypes:
            try:
                dtype = dict(
                    i=np.int16, f=np.float32, u=np.uint16, b=np.uint8
                )[dtype.kind]
            except KeyError:  # not an int or float
                raise TypeError(
                    f'type {dtype} not allowed for texture; must be one of {set(texture_dtypes)}'  # noqa: E501
                )
            data = data.astype(dtype)

        if self.layer.dims.ndisplay == 3 and self.layer.dims.ndim == 2:
            data = np.expand_dims(data, axis=0)

        # Check if data exceeds MAX_TEXTURE_SIZE and downsample
        if (
            self.MAX_TEXTURE_SIZE_2D is not None
            and self.layer.dims.ndisplay == 2
        ):
            data = self.downsample_texture(data, self.MAX_TEXTURE_SIZE_2D)
        elif (
            self.MAX_TEXTURE_SIZE_3D is not None
            and self.layer.dims.ndisplay == 3
        ):
            data = self.downsample_texture(data, self.MAX_TEXTURE_SIZE_3D)

        # Check if ndisplay has changed current node type needs updating
        if (
            self.layer.dims.ndisplay == 3
            and not isinstance(self.node, VolumeNode)
        ) or (
            self.layer.dims.ndisplay == 2
            and not isinstance(self.node, ImageNode)
        ):
            self._on_display_change(data)
        else:
            if self.layer.dims.ndisplay == 2:
                self.node._need_colortransform_update = True
                self.node.set_data(data)
            else:
                self.node.set_data(data, clim=self.layer.contrast_limits)

        # Call to update order of translation values with new dims:
        self._on_scale_change()
        self._on_translate_change()
        self.node.update() 
开发者ID:napari,项目名称:napari,代码行数:53,代码来源:vispy_image_layer.py


注:本文中的vispy.scene.visuals.Image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。