Example #1
0
def compute_affine_transformation3d(
        input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Compute the applied transformation matrix :math: `(*, 4, 4)`.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape (D, H, W), (C, D, H, W), (B, C, D, H, W).
        params (Dict[str, torch.Tensor]):
            - params['angles']: Degrees of rotation with the shape of :math: `(*, 3)` for yaw, pitch, roll.
            - params['translations']: Horizontal, vertical and depthical translations (dx,dy,dz).
            - params['center']: Rotation center (x,y,z).
            - params['scale']: Isotropic scaling params.
            - params['sxy']: Shear param toward x-y-axis.
            - params['sxz']: Shear param toward x-z-axis.
            - params['syx']: Shear param toward y-x-axis.
            - params['syz']: Shear param toward y-z-axis.
            - params['szx']: Shear param toward z-x-axis.
            - params['szy']: Shear param toward z-y-axis.

    Returns:
        torch.Tensor: The applied transformation matrix :math: `(*, 4, 4)`
    """
    input = _transform_input3d(input)
    _validate_input_dtype(
        input, accepted_dtypes=[torch.float16, torch.float32, torch.float64])
    transform = get_affine_matrix3d(params['translations'], params['center'],
                                    params['scale'], params['angles'],
                                    deg2rad(params['sxy']),
                                    deg2rad(params['sxz']),
                                    deg2rad(params['syx']),
                                    deg2rad(params['syz']),
                                    deg2rad(params['szx']),
                                    deg2rad(params['szy'])).type_as(input)
    return transform
Example #2
0
def compute_affine_transformation3d(input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Compute the affine transformation matrix :math: `(*, 4, 4)`.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape :math:`(*, C, D, H, W)`.
        params (Dict[str, torch.Tensor]):
            - params['angles']: Degrees of rotation with the shape of :math: `(*, 3)` for yaw, pitch, roll.
            - params['translations']: Horizontal, vertical and depthical translations (dx,dy,dz).
            - params['center']: Rotation center (x,y,z).
            - params['scale']: Isotropic scaling params.
            - params['sxy']: Shear param toward x-y-axis.
            - params['sxz']: Shear param toward x-z-axis.
            - params['syx']: Shear param toward y-x-axis.
            - params['syz']: Shear param toward y-z-axis.
            - params['szx']: Shear param toward z-x-axis.
            - params['szy']: Shear param toward z-y-axis.

    Returns:
        torch.Tensor: The affine transformation matrix :math: `(*, 4, 4)`.
    """
    transform = get_affine_matrix3d(
        params['translations'], params['center'], params['scale'], params['angles'],
        deg2rad(params['sxy']), deg2rad(params['sxz']), deg2rad(params['syx']),
        deg2rad(params['syz']), deg2rad(params['szx']), deg2rad(params['szy'])
    ).to(input)
    return transform
Example #3
0
 def compute_transformation(self, input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
     transform: torch.Tensor = get_affine_matrix3d(
         params["translations"],
         params["center"],
         params["scale"],
         params["angles"],
         deg2rad(params["sxy"]),
         deg2rad(params["sxz"]),
         deg2rad(params["syx"]),
         deg2rad(params["syz"]),
         deg2rad(params["szx"]),
         deg2rad(params["szy"]),
     ).to(input)
     return transform
Example #4
0
 def compute_transformation(self, input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
     transform: torch.Tensor = get_affine_matrix3d(
         params['translations'],
         params['center'],
         params['scale'],
         params['angles'],
         deg2rad(params['sxy']),
         deg2rad(params['sxz']),
         deg2rad(params['syx']),
         deg2rad(params['syz']),
         deg2rad(params['szx']),
         deg2rad(params['szy']),
     ).to(input)
     return transform