scistag.plotstag.layers.image_layer.ImageLayer

class ImageLayer(image, size_ratio=None, bg_fill='cb')[source]

Bases: PlotLayer

Visualizes an image on a plot.

Parameters
  • image (Image | np.ndarray) – The image to plot

  • size_ratio (float | tuple[float, float] | None) –

    The size ratio from the image’s or matrix original size to effective pixels. This can be used to plot images in original size rather than being auto-scaled through the plot’s configuration.

    • 1.0 = keep the original size.

    • 0.5 = 50% of the original size

  • bg_fill (str | Color | None) –

    Defines the background which shall be used if the image is alpha-transparent. If a color is passed the whole background will be filled with given color.

    ”cb” (checkerboard) by default.

Methods

generate_checkerboard

Renders a checkerboard as background for transparent images :rtype: Image :return: The checkerboard graphic

paint

Paints the layer's content :type canvas: Canvas :param canvas: The target canvas into which the content shall be painted.

update_layout

Updates the layout (especially .size) with the size foreseen by the plot :type desired_size: Size2D | None :param desired_size: The proposed size by the plot :type forced_size: Size2D | None :param forced_size: Enforced size i f the size can under no circumstances be influenced by a layer.

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

_image

The image to be plotted

_scaled_image

The scaled version of the image to be plotted

needs_clipping

Defines if the whole content shall be rendered into a separated clippable canvas

bg_fill

Defines the way the background is filled if he image is alpha- transparent.

static generate_checkerboard()[source]

Renders a checkerboard as background for transparent images :rtype: Image :return: The checkerboard graphic

paint(canvas)[source]

Paints the layer’s content :type canvas: Canvas :param canvas: The target canvas into which the content shall be

painted.

update_layout(desired_size=None, forced_size=None)[source]

Updates the layout (especially .size) with the size foreseen by the plot :type desired_size: Size2D | None :param desired_size: The proposed size by the plot :type forced_size: Size2D | None :param forced_size: Enforced size i f the size can under no

circumstances be influenced by a layer.

_image

The image to be plotted

_scaled_image

The scaled version of the image to be plotted

bg_fill: str | Color | None

Defines the way the background is filled if he image is alpha- transparent. Either with a color or a checkerboard (“cb”)

fixed_size: Size2D | None

The fixed size. If specified the plot will try to enforce this size

needs_clipping

Defines if the whole content shall be rendered into a separated clippable canvas

size: Size2D

The effective size of this layer in pixels

value_range: PlotValueRange2D | PlotValueRange3D

The range of the values stored in this layer