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
roiare set toTrue; all other pixels areFalse.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, orVoxelArraydefining 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_image
darsia.Image A
Imageused to define the output shape, metadata and coordinate system.- mode
Literal[‘shape’, ‘voxels’] Passed through to
zeros_like(); controls whether the output has the full image shape ("shape") or only the voxel dimensions ("voxels").
- roi
- Returns: