def apply_crop3d(input: torch.Tensor, params: Dict[str, torch.Tensor], flags: Dict[str, torch.Tensor]) -> torch.Tensor: r"""Apply cropping by src bounding box and dst bounding box. Args: input (torch.Tensor): Tensor to be transformed with shape :math:`(*, C, D, H, W)`. params (Dict[str, torch.Tensor]): - params['src']: The applied cropping src matrix :math: `(*, 8, 3)`. - params['dst']: The applied cropping dst matrix :math: `(*, 8, 3)`. flags (Dict[str, torch.Tensor]): - params['interpolation']: Integer tensor. NEAREST = 0, BILINEAR = 1. - params['align_corners']: Boolean tensor. Returns: torch.Tensor: The cropped input. Note: BBox order: front-top-left, front-top-right, front-bottom-right, front-bottom-left, back-top-left, back-top-right, back-bottom-right, back-bottom-left. The coordinates must be in x, y, z order. """ resample_mode: str = Resample.get(flags['interpolation'].item()).name.lower() # type: ignore align_corners: bool = cast(bool, flags['align_corners'].item()) return crop_by_boxes3d( input, params['src'], params['dst'], resample_mode, align_corners=align_corners)
def apply_crop3d(input: torch.Tensor, params: Dict[str, torch.Tensor], flags: Dict[str, torch.Tensor]) -> torch.Tensor: r"""Apply cropping by src bounding box and dst bounding box. Order: front-top-left, front-top-right, front-bottom-right, front-bottom-left, back-top-left, back-top-right, back-bottom-right, back-bottom-left. The coordinates must be in x, y, z order. - params['src']: The applied cropping src matrix :math: `(*, 8, 3)`. - params['dst']: The applied cropping dst matrix :math: `(*, 8, 3)`. flags (Dict[str, torch.Tensor]): - params['interpolation']: Integer tensor. NEAREST = 0, BILINEAR = 1. - params['align_corners']: Boolean tensor. Returns: torch.Tensor: The cropped input. """ input = _transform_input3d(input) _validate_input_dtype( input, accepted_dtypes=[torch.float16, torch.float32, torch.float64]) resample_mode: str = Resample.get( flags['interpolation'].item()).name.lower() # type: ignore align_corners: bool = cast(bool, flags['align_corners'].item()) return crop_by_boxes3d(input, params['src'], params['dst'], resample_mode, align_corners=align_corners)