HLS#
Tip
Learn more: https://en.wikipedia.org/wiki/HSL_and_HSV
Note
Hue is returned in radians in \([0, 2\pi)\); see Conventions & Pitfalls.
Functions#
- kornia.color.rgb_to_hls(image, eps=1e-8)[source]#
Convert an RGB image to HLS.
hls = rgb_to_hls(image)converts a(*, 3, H, W)RGB image in \([0, 1]\) to hue, lightness and saturation.
- Convention:
Channels are H, L, S at axis -3. Hue is measured in radians in \([0, 2\pi)\), unlike OpenCV, which uses degrees (halved for 8-bit images).
- Parameters:
- Return type:
- Returns:
HLS image with shape
(*, 3, H, W).
See also
hls_to_rgb(): the inverse.RgbToHls: the module form, which has noepsand uses the default.
Example
>>> input = torch.rand(2, 3, 4, 5) >>> output = rgb_to_hls(input) # 2x3x4x5
- kornia.color.hls_to_rgb(image)[source]#
Convert an HLS image to RGB.
rgb = hls_to_rgb(image)converts a(*, 3, H, W)image of hue in radians, lightness in \([0, 1]\) and saturation in \([0, 1]\) to RGB.- Convention:
Channels are H, L, S at axis -3. Hue wraps modulo 2π. The result is not clipped, so lightness or saturation outside \([0, 1]\) can give RGB values outside it.
- Parameters:
image (
Tensor) – HLS image with shape(*, 3, H, W).- Return type:
- Returns:
RGB image with shape
(*, 3, H, W).
See also
rgb_to_hls(): the inverse.HlsToRgb: the module form.
Example
>>> input = torch.rand(2, 3, 4, 5) >>> output = hls_to_rgb(input) # 2x3x4x5
Modules#
- class kornia.color.RgbToHls(*args, **kwargs)[source]#
Convert an image from RGB to HLS (module form).
out = RgbToHls()(image)isrgb_to_hls()with its defaulteps.- Convention:
See the convention block of
rgb_to_hls().
- Shape:
image:
(*, 3, H, W)output:
(*, 3, H, W)
See also
rgb_to_hls(): the one-call form, with anepsargument.HlsToRgb: the inverse.
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> hls = RgbToHls() >>> output = hls(input) # 2x3x4x5
- class kornia.color.HlsToRgb(*args, **kwargs)[source]#
Convert an image from HLS to RGB (module form).
out = HlsToRgb()(image)ishls_to_rgb().- Convention:
See the convention block of
hls_to_rgb().
- Shape:
image:
(*, 3, H, W)output:
(*, 3, H, W)
See also
hls_to_rgb(): the one-call form.RgbToHls: the inverse.
References
https://en.wikipedia.org/wiki/HSL_and_HSV
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> rgb = HlsToRgb() >>> output = rgb(input) # 2x3x4x5