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 bounding-box masks.

Parameters:
roi_SingleRoi | list[_SingleRoi]

A single ROI, CoordinateArray, or VoxelArray defining the bounding-box corners, or a list of such objects whose union is returned. If a pair of coordinates is provided, it must be in the form of a 2-D array with shape (2, 2), where the first row is the minimum corner and the second row is the maximum corner.

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.