scallops.visualize.composite.imcomposite
- scallops.visualize.composite.imcomposite(image=None, labels=None, vmin=None, vmax=None, cmap=None, labels_cmap=None, labels_alpha=0.5, labels_contour=False, labels_contour_cmap=None, labels_contour_thickness=1, labels_contour_alpha=1, dim='c', facet=None, col_wrap=3, figsize=None, ax=None, rgb=False, mask=None)
Plot an image composite using additive blending.
- Parameters:
image (DataArray | ndarray | Array | None) – XArray with dimensions y, x and optionally dim.
labels (DataArray | ndarray | Array | None) – Labels (e.g., segmentation labels).
vmin (float | DataArray | ndarray | Array | None) – Lower color limit used for determining the colormap bounds. Default is the minimum of the image. If a list, must be the same length as the dimension being expanded.
vmax (float | DataArray | ndarray | Array | None) – Upper color limit used for determining the colormap bounds. Default is the maximum of the image. If a list, must be the same length as the dimension being expanded.
figsize (tuple[int, int]) – Figure size.
cmap (Sequence[str | Colormap] | str | Colormap | None) – List that maps dimension index to colormap instance or registered colormap name used to map scalar data to colors.
labels_cmap (str | ListedColormap | None) – ListedColormap instance or registered colormap name used to map label data to colors.
labels_alpha (float) – Alpha value for labels.
labels_contour (bool | ndarray | DataArray | Array) – If true, show label contours only. If an array, then segmentation labels to show as contour.
labels_contour_cmap (str | ListedColormap | None) – ListedColormap instance or registered colormap name used to map label contour data to colors.
labels_contour_thickness (int) – Labels contour thickness.
labels_contour_alpha (float) – Alpha value for label contours.
labels_cmap – ListedColormap instance or registered colormap name used to map label data to colors.
dim (str | None) – Image dimension to blend.
facet (str | None) – Image dimension to plot on different facet.
col_wrap (int | None) – Wrap the facet variable at this width, so that the facet values span multiple rows.
ax (Axes | Sequence[Axes] | None) – Matplotlib axes to plot to. If facet is provided, a one dimensional array of axes corresponding to
rgb (bool)
mask (ndarray | DataArray | Array)
- Return type:
Axes | Sequence[Axes]
length of facet values :param rgb: Whether the image is RGB or RGBA. :param mask: Mask pixels where mask == 0
- Example:
from matplotlib import pyplot as plt import numpy as np import xarray as xr from scallops.visualize import imcomposite # Generate synthetic data for testing t, c, z, y, x = ( 1, 3, 1, 10, 10, ) # emulate all possible dimensions (only 3D is accepted by single) image_data = np.random.rand(t, c, z, y, x) labels_data = np.random.randint(0, 2, size=(y, x)) image = xr.DataArray(image_data, dims=("t", "c", "z", "y", "x")) labels = xr.DataArray(labels_data, dims=("y", "x")) # Plot the composite image ax = imcomposite(image.isel(t=0, z=0), labels, figsize=(8, 8), dim="c") plt.show()
- Parameters:
image (DataArray | ndarray | Array | None)
labels (DataArray | ndarray | Array | None)
vmin (float | DataArray | ndarray | Array | None)
vmax (float | DataArray | ndarray | Array | None)
cmap (Sequence[str | Colormap] | str | Colormap | None)
labels_cmap (str | ListedColormap | None)
labels_alpha (float)
labels_contour (bool | ndarray | DataArray | Array)
labels_contour_cmap (str | ListedColormap | None)
labels_contour_thickness (int)
labels_contour_alpha (float)
dim (str | None)
facet (str | None)
col_wrap (int | None)
figsize (tuple[int, int])
ax (Axes | Sequence[Axes] | None)
rgb (bool)
mask (ndarray | DataArray | Array)
- Return type:
Axes | Sequence[Axes]