YCbCr#
Tip
Learn more: https://en.wikipedia.org/wiki/YCbCr
Functions#
- kornia.color.rgb_to_ycbcr(image)[source]#
Convert an RGB image to YCbCr.
- Convention:
Channels are Y, Cb, Cr at axis -3. RGB inputs and all output channels use unit-range full-range values.
- Parameters:
image (
Tensor) – RGB Image to be converted to YCbCr with shape \((*, 3, H, W)\).- Return type:
- Returns:
YCbCr version of the image with shape \((*, 3, H, W)\).
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> output = rgb_to_ycbcr(input) # 2x3x4x5
- kornia.color.rgb_to_y(image)[source]#
Convert an RGB image to Y.
- Convention:
Returns the Y channel from the unit-range full-range YCbCr convention used by rgb_to_ycbcr.
- Parameters:
image (
Tensor) – RGB Image to be converted to Y with shape \((*, 3, H, W)\).- Return type:
- Returns:
Y version of the image with shape \((*, 1, H, W)\).
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> output = rgb_to_y(input) # 2x1x4x5
- kornia.color.ycbcr_to_rgb(image)[source]#
Convert an YCbCr image to RGB.
The image data is assumed to be in the range of (0, 1).
- Convention:
Expects unit-range, full-range Y, Cb, Cr channels at axis -3 as produced by rgb_to_ycbcr. The final RGB result is clamped to [0, 1].
- Parameters:
image (
Tensor) – YCbCr Image to be converted to RGB with shape \((*, 3, H, W)\).- Return type:
- Returns:
RGB version of the image with shape \((*, 3, H, W)\).
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> output = ycbcr_to_rgb(input) # 2x3x4x5
Modules#
- class kornia.color.RgbToYcbcr(*args, **kwargs)[source]#
Convert an image from RGB to YCbCr.
See the Convention block on
rgb_to_ycbcr().The image data is assumed to be in the range of (0, 1).
- Returns:
YCbCr version of the image.
- Shape:
image: \((*, 3, H, W)\)
output: \((*, 3, H, W)\)
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> ycbcr = RgbToYcbcr() >>> output = ycbcr(input) # 2x3x4x5
- class kornia.color.YcbcrToRgb(*args, **kwargs)[source]#
Convert an image from YCbCr to Rgb.
See the Convention block on
ycbcr_to_rgb().The image data is assumed to be in the range of (0, 1).
- Returns:
RGB version of the image.
- Shape:
image: \((*, 3, H, W)\)
output: \((*, 3, H, W)\)
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> rgb = YcbcrToRgb() >>> output = rgb(input) # 2x3x4x5