Visualization types

These types and functions support image display. Makie plot verbs (heatmap!, scatter!, poly!) are defined in the Makie extension and dispatch on SpatialImage, SpatialPoints, and SpatialShapes directly — see the Visualization guide for usage patterns.

Image types

SpatialOmics.SpatialImageType
SpatialImage{T, N}

N-dimensional raster image in a named coordinate system, optionally with pre-computed pyramid levels.

The image data array has axes labelled by axes — a tuple of symbols such as (:c, :y, :x) for a 3-D multi-channel image or (:y, :x) for a 2-D image. The pixel_to_cs transformation maps pixel-space indices to the physical coordinate system. Pyramid levels (coarser sub-sampled copies) are stored in pyramid and can be built with build_pyramid!.

A display_transform (e.g. from scaleminmax) is applied after data materialisation at render time, never wrapped around Zarr arrays.

Constructors

SpatialImage(data; axes, channel_names, coord_system, pixel_to_cs, pyramid, display_transform)

See also

SpatialLabels, channel, scaleminmax, build_pyramid!, colorview

SpatialOmics.SpatialLabelsType
SpatialLabels{T<:Integer, N}

Integer segmentation mask in a named coordinate system, where each pixel value identifies an object instance.

The instance_map dictionary maps raw pixel label values to canonical instance_id values, matching the convention used in SpatialPoints and SpatialShapes. Use instance_ids(lbl) to list all non-background instances.

Constructors

SpatialLabels(data; axes, instance_map, coord_system, pixel_to_cs)

See also

SpatialImage, instance_ids, data

SpatialOmics.SpatialImageColorViewType
SpatialImageColorView{C<:Colorant, T, N}

Display-only wrapper that pairs a SpatialImage with a colorant type and an optional scalar display transform.

Produced by colorview(CT, img), colorview(CT, img, ch), or colorview(CT, img1, img2, ...) for RGB composites. The display_transform (if any) is applied after Zarr materialisation, never wrapping disk arrays.

See also

colorview, scaleminmax, channel

Image utilities

SpatialOmics.channelFunction
channel(img, ch) → SpatialImage

Return a lazy view of a single channel from a multi-channel SpatialImage.

ch can be an Int (1-based channel index) or a String (channel name from channel_names(img)). The result is a 2-D SpatialImage with the channel axis removed. Pyramid levels are sliced correspondingly.

See also

nchannels, channel_names, colorview

ImageCore.scaleminmaxFunction
scaleminmax(img) → SpatialImage

Return a copy of img with a min-max intensity rescaling transform set as its display_transform.

The intensity range is sampled from the coarsest pyramid level (a fast single bulk read). The transform is applied after Zarr materialisation at display time — it is never wrapped around lazy disk arrays.

See also

channel, colorview, build_pyramid!

ImageCore.colorviewFunction
colorview(CT, img) → SpatialImageColorView
colorview(CT, img, ch) → SpatialImageColorView
colorview(CT, img1, img2, ...) → SpatialImageColorView

Wrap one or more SpatialImage objects with colorant type CT for display.

Single-image forms extract channel(img, 1) if img is multi-channel unless ch is specified. The multi-image form creates an RGB (or N-channel) composite; all inputs must be 2-D (call channel first).

cview = colorview(Gray, scaleminmax(channel(img, 1)))

See also

SpatialImageColorView, channel, scaleminmax

SpatialOmics.build_pyramid!Function
build_pyramid!(img, n_levels=3) → img

Build a Gaussian downsampling pyramid in-place, storing n_levels progressively coarser arrays in img.pyramid.

Each level halves the spatial resolution along the :x and :y axes using ImageBase.restrict. The channel axis (:c) is not downsampled. Existing pyramid levels are discarded before building.

See also

scaleminmax, channel

SpatialOmics.dataFunction
data(img) → AbstractArray

Return the underlying data array of a SpatialImage or SpatialLabels. May be a Zarr-backed DiskArray — use Array(data(img)) to force a full read.

Re-exported color types

Gray and RGB are re-exported from Colors.jl. Use them as the colorant argument to colorview:

cview = colorview(Gray, scaleminmax(channel(img, 1)))
rgb   = colorview(RGB,  channel(img, 1), channel(img, 2), channel(img, 3))