batch_sub_crop

lib.align.aligned_utils.batch_sub_crop(images: npt.NDArray[np.uint8], offsets: npt.NDArray[np.int32], out_size: int, base_grid: tuple[npt.NDArray[np.int32], npt.NDArray[np.int32]] | None = None) npt.NDArray[np.uint8]
lib.align.aligned_utils.batch_sub_crop(images: npt.NDArray[np.float32], offsets: npt.NDArray[np.int32], out_size: int, base_grid: tuple[npt.NDArray[np.int32], npt.NDArray[np.int32]] | None = None) npt.NDArray[np.float32]

Obtain aligned sub-crops from larger aligned images. Handles OOB. Outputs are replicate padded

Parameters:
  • images (npt.NDArray[np.uint8 | np.float32]) – The (N, H, W, C) full size extracted images

  • offsets (npt.NDArray[np.int32]) – The (N, x, y) offsets to shift the sub-crops.

  • out_size (int) – The output size of the sub-crop

  • base_grid (tuple[npt.NDArray[np.int32], npt.NDArray[np.int32]] | None) – Pre-computed base mesh grid used to build crop indices. Should be a tuple (yy, xx) where each entry is a numpy array (int32) of shape (out_size, out_size) of row/column indices starting at 0, Providing this avoids rebuilding the meshgrid on every call. Default: None (calculate within the function)

Return type:

npt.NDArray[np.uint8 | np.float32]