Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and egidioln committed Sep 9, 2024
1 parent 57ca8f1 commit 2cafaa7
Showing 1 changed file with 66 additions and 26 deletions.
92 changes: 66 additions & 26 deletions kornia/color/yuv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ def rgb_to_yuv(image: Tensor) -> Tensor:
.. image:: _static/img/rgb_to_yuv.png
The image data is assumed to be in the range of :math:`(0, 1)`. The range of the output is of :math:`(0, 1)` to luma and the ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
The YUV model adopted here follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)`. The range of the output is of
:math:`(0, 1)` to luma and the ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`,
respectively.
The YUV model adopted here follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Args:
image: RGB Image to be converted to YUV with shape :math:`(*, 3, H, W)`.
Expand Down Expand Up @@ -48,9 +53,12 @@ def rgb_to_yuv420(image: Tensor) -> Tuple[Tensor, Tensor]:
Input need to be padded to be evenly divisible by 2 horizontal and vertical.
The image data is assumed to be in the range of :math:`(0, 1)`. The range of the output is of :math:`(0, 1)` to luma and the ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
The YUV model adopted here follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)`. The range of the output is of :math:`(0, 1)` to
luma and the ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
The YUV model adopted here follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Args:
image: RGB Image to be converted to YUV with shape :math:`(*, 3, H, W)`.
Expand Down Expand Up @@ -82,8 +90,13 @@ def rgb_to_yuv422(image: Tensor) -> Tuple[Tensor, Tensor]:
Input need to be padded to be evenly divisible by 2 vertical.
The image data is assumed to be in the range of :math:`(0, 1)`. The range of the output is of :math:`(0, 1)` to luma and the ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
The YUV model adopted here follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)`. The range of the output is of
:math:`(0, 1)` to luma and the ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`,
respectively.
The YUV model adopted here follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Args:
image: RGB Image to be converted to YUV with shape :math:`(*, 3, H, W)`.
Expand Down Expand Up @@ -113,8 +126,12 @@ def rgb_to_yuv422(image: Tensor) -> Tuple[Tensor, Tensor]:
def yuv_to_rgb(image: Tensor) -> Tensor:
r"""Convert an YUV image to RGB.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are
:math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Args:
image: YUV Image to be converted to RGB with shape :math:`(*, 3, H, W)`.
Expand Down Expand Up @@ -150,8 +167,12 @@ def yuv420_to_rgb(imagey: Tensor, imageuv: Tensor) -> Tensor:
Input need to be padded to be evenly divisible by 2 horizontal and vertical.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are
:math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Args:
imagey: Y (luma) Image plane to be converted to RGB with shape :math:`(*, 1, H, W)`.
Expand Down Expand Up @@ -200,10 +221,14 @@ def yuv420_to_rgb(imagey: Tensor, imageuv: Tensor) -> Tensor:
def yuv422_to_rgb(imagey: Tensor, imageuv: Tensor) -> Tensor:
r"""Convert an YUV422 image to RGB.
Input need to be padded to be evenly divisible by 2 vertical.
Input need to be padded to be evenly divisible by 2 vertical.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are
:math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Args:
imagey: Y (luma) Image plane to be converted to RGB with shape :math:`(*, 1, H, W)`.
Expand Down Expand Up @@ -248,7 +273,9 @@ class RgbToYuv(Module):
The image data is assumed to be in the range of :math:`(0, 1)`.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Returns:
YUV version of the image.
Expand Down Expand Up @@ -277,7 +304,9 @@ class RgbToYuv420(Module):
The image data is assumed to be in the range of :math:`(0, 1)`.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Returns:
YUV420 version of the image.
Expand All @@ -304,9 +333,11 @@ class RgbToYuv422(Module):
Width must be evenly disvisible by 2.
The image data is assumed to be in the range of :math:`(0, 1)`.
The image data is assumed to be in the range of :math:`(0, 1)`.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Returns:
YUV422 version of the image.
Expand All @@ -331,9 +362,12 @@ def forward(self, yuvinput: Tensor) -> Tuple[Tensor, Tensor]: # skipcq: PYL-R02
class YuvToRgb(Module):
r"""Convert an image from YUV to RGB.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are
:math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Returns:
RGB version of the image.
Expand All @@ -357,9 +391,12 @@ class Yuv420ToRgb(Module):
Width and Height must be evenly divisible by 2.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are
:math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Returns:
RGB version of the image.
Expand All @@ -384,10 +421,13 @@ class Yuv422ToRgb(Module):
r"""Convert an image from YUV to RGB.
Width must be evenly divisible by 2.
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are :math:`(-0.436, 0.436)` and :math:`(−0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see [BT.470-5](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf), Table 2, items 2.5 and 2.6).
The image data is assumed to be in the range of :math:`(0, 1)` for luma (Y). The ranges of U and V are
:math:`(-0.436, 0.436)` and :math:`(-0.615, 0.615)`, respectively.
YUV formula follows M/PAL values (see
`BT.470-5 <(https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf>`, Table 2,
items 2.5 and 2.6).
Returns:
RGB version of the image.
Expand Down

0 comments on commit 2cafaa7

Please sign in to comment.