vispy.visuals.image module

class vispy.visuals.image.ImageVisual(data=None, method='auto', grid=(1, 1), cmap='viridis', clim='auto', gamma=1.0, interpolation='nearest', **kwargs)[source]

Bases: vispy.visuals.visual.Visual

Visual subclass displaying an image.

Parameters
datandarray

ImageVisual data. Can be shape (M, N), (M, N, 3), or (M, N, 4).

methodstr

Selects method of rendering image in case of non-linear transforms. Each method produces similar results, but may trade efficiency and accuracy. If the transform is linear, this parameter is ignored and a single quad is drawn around the area of the image.

  • ‘auto’: Automatically select ‘impostor’ if the image is drawn with a nonlinear transform; otherwise select ‘subdivide’.

  • ‘subdivide’: ImageVisual is represented as a grid of triangles with texture coordinates linearly mapped.

  • ‘impostor’: ImageVisual is represented as a quad covering the entire view, with texture coordinates determined by the transform. This produces the best transformation results, but may be slow.

grid: tuple (rows, cols)

If method=’subdivide’, this tuple determines the number of rows and columns in the image grid.

cmapstr | ColorMap

Colormap to use for luminance images.

climstr | tuple

Limits to use for the colormap. Can be ‘auto’ to auto-set bounds to the min and max of the data.

gammafloat

Gamma to use during colormap lookup. Final color will be cmap(val**gamma). by default: 1.

interpolationstr

Selects method of image interpolation. Makes use of the two Texture2D interpolation methods and the available interpolation methods defined in vispy/gloo/glsl/misc/spatial_filters.frag

  • ‘nearest’: Default, uses ‘nearest’ with Texture2D interpolation.

  • ‘bilinear’: uses ‘linear’ with Texture2D interpolation.

  • ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘bicubic’,

    ‘catrom’, ‘mitchell’, ‘spline16’, ‘spline36’, ‘gaussian’, ‘bessel’, ‘sinc’, ‘lanczos’, ‘blackman’

**kwargsdict

Keyword arguments to pass to Visual.

Notes

The colormap functionality through cmap and clim are only used if the data are 2D.

property clim
property clim_normalized

Normalize current clims between 0-1 based on last-used texture data range. In _build_texture(), the data is normalized (on the CPU) to 0-1 using clim. During rendering, the frag shader will apply the final contrast adjustment based on the current clim.

property cmap
property gamma

The gamma used when rendering the image.

property interpolation
property interpolation_functions
property method
set_data(image)[source]

Set the data

Parameters
imagearray-like

The image data.

property size
view()[source]

Return a new view of this visual.