當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。