Beispiel #1
0
def apply_equalize(input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Equalize an image.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape :math:`(*, C, H, W)`.

    Returns:
        torch.Tensor: Adjusted image with shape :math:`(B, C, H, W)`.
    """
    return equalize(input)
Beispiel #2
0
def apply_equalize(input: torch.Tensor,
                   params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Equalize an image.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape (H, W), (C, H, W), (B, C, H, W).

    Returns:
        torch.Tensor: Adjusted image.
    """
    input = _transform_input(input)
    _validate_input_dtype(
        input, accepted_dtypes=[torch.float16, torch.float32, torch.float64])

    return equalize(input)
Beispiel #3
0
def apply_equalize(input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Equalize an image.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape (H, W), (C, H, W), (B, C, H, W).
        params (Dict[str, torch.Tensor]):
            - params['p']: Probability.

    Returns:
        torch.Tensor: Adjusted image.
    """
    input = _transform_input(input)
    _validate_input_dtype(input, accepted_dtypes=[torch.float16, torch.float32, torch.float64])

    res = []
    for image, prob in zip(input, params['batch_prob']):
        res.append(equalize(image) if prob else image)
    return torch.cat(res, dim=0)
Beispiel #4
0
def add_equal(img, x):
    img_norm = img / torch.max(img)
    img_eq = equalize(img_norm)
    return torch.lerp(img_norm, img_eq, x)
Beispiel #5
0
 def apply_transform(self,
                     input: Tensor,
                     params: Dict[str, Tensor],
                     transform: Optional[Tensor] = None) -> Tensor:
     return equalize(input)