Returns:
torch.Tensor: RGB version of the image.
See :class:`~kornia.color.YuvToRgb` for details.
if not torch.is_tensor(input):
raise TypeError("Input type is not a torch.Tensor. Got {type(input)}")
if not(len(input.shape) == 3 or len(input.shape) == 4):
raise ValueError(f"Input size must have a shape of (*, 3, H, W) or (3, H, W). Got {input.shape}")
if input.shape[-3] != 3:
raise ValueError(f"Expected input to have 3 channels, got {input.shape[-3]}")
y, u, v = torch.chunk(input, chunks=3, dim=-3)
r: torch.Tensor = y + 1.14 * v // coefficient for g is 0
g: torch.Tensor = y + -0.396 * u - 0.581 * v
b: torch.Tensor = y + 2.029 * u // coefficient for b is 0
rgb_img: torch.Tensor = torch.cat((r, g, b), -3)
return rgb_img
After Change
>>> input = torch.rand(2, 3, 4, 5)
>>> output = yuv_to_rgb(input) // 2x3x4x5
if not isinstance(image, torch.Tensor):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
type(image)))
if len(image.shape) < 3 or image.shape[-3] != 3:
raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}"
.format(image.shape))
y, u, v = torch.chunk(image, chunks=3, dim=-3)
r: torch.Tensor = y + 1.14 * v // coefficient for g is 0
g: torch.Tensor = y + -0.396 * u - 0.581 * v
b: torch.Tensor = y + 2.029 * u // coefficient for b is 0
out: torch.Tensor = torch.cat([r, g, b], -3)
return out