scanpy.pl.spatial
has an option crop=None
that automatically crops the image to the extent of the shapes:
Coordinates to use for cropping the image (left, right, top, bottom). These coordinates are expected to be in pixel space (same as
basis
) and will be transformed byscale_factor
. If not provided, image is automatically cropped to bounds ofbasis
, plus a border.
I find this a very useful default for Cytassist visium samples, because the majority of the image will be empty space plus the fiducial frame. In spatialdata, I could probably do a bounding box query to achieve something similar. But how would I get the coordinates of the respective bounding box?