dataeval.utils.preprocessing.clip_and_pad

dataeval.utils.preprocessing.clip_and_pad(image, box)

Extract a region from an image based on a bounding box.

Clips to image boundaries and pads out-of-bounds areas with np.nan.

Parameters:
image : NDArray

Input image array in format C, H, W (channels first)

box : Box

Bounding box coordinates as (x0, y0, x1, y1) where (x0, y0) is top-left and (x1, y1) is bottom-right

Returns:

The extracted region with out-of-bounds areas padded with np.nan

Return type:

NDArray