HLS#

Functions#

kornia.color.rgb_to_hls(image, eps=1e-8)[source]#

Convert an RGB image to HLS.

_images/rgb_to_hls.png

The image data is assumed to be in the range of (0, 1).

NOTE: this method cannot be compiled with JIT in pytohrch < 1.7.0

Parameters:
  • image (Tensor) – RGB image to be converted to HLS with shape \((*, 3, H, W)\).

  • eps (float, optional) – epsilon value to avoid div by zero. Default: 1e-8

Return type:

Tensor

Returns:

HLS version of the image with shape \((*, 3, H, W)\).

Example

>>> input = torch.rand(2, 3, 4, 5)
>>> output = rgb_to_hls(input)  # 2x3x4x5
kornia.color.hls_to_rgb(image)[source]#

Convert a HLS image to RGB.

The image data is assumed to be in the range of (0, 1).

Parameters:

image (Tensor) – HLS image to be converted to RGB with shape \((*, 3, H, W)\).

Return type:

Tensor

Returns:

RGB version of the image with shape \((*, 3, H, W)\).

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.

The image data is assumed to be in the range of (0, 1).

Returns:

HLS version of the image.

Shape:
  • image: \((*, 3, H, W)\)

  • output: \((*, 3, H, W)\)

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.

The image data is assumed to be in the range of (0, 1).

Returns:

RGB version of the image.

Shape:
  • input: \((*, 3, H, W)\)

  • output: \((*, 3, H, W)\)

Reference:

https://en.wikipedia.org/wiki/HSL_and_HSV

Examples

>>> input = torch.rand(2, 3, 4, 5)
>>> rgb = HlsToRgb()
>>> output = rgb(input)  # 2x3x4x5