darsia.roi_to_mask#

roi_to_mask(roi, reference_image, mode='shape')[source]#

Create a full-domain boolean mask image from one or more bounding-box ROIs.

The returned image has the same spatial extent and coordinate system as reference_image. Pixels whose centres fall inside the axis-aligned bounding box defined by roi are set to True; all other pixels are False.

When roi is a list, the returned mask is the element-wise union (logical OR) of the individual masks.

Parameters:
roi_SingleRoi | list[_SingleRoi]

A single ROI, CoordinateArray, or VoxelArray, or a list of such objects whose union is returned. A pair of coordinates (shape (2, 2), first row the minimum corner, second row the maximum corner) is treated as an axis-aligned box. More than two, ordered points are treated as a polygon and rasterized to their true footprint, not their bounding box.

reference_imagedarsia.Image

A Image used to define the output shape, metadata and coordinate system.

modeLiteral[‘shape’, ‘voxels’]

Passed through to zeros_like(); controls whether the output has the full image shape ("shape") or only the voxel dimensions ("voxels").

Returns:
A bool Image (same type/shape as.
reference_image) with True inside the bounding box(es) and.
False everywhere else.