HLS#
Tip
Learn more: https://en.wikipedia.org/wiki/HSL_and_HSV
Functions#
- kornia.color.rgb_to_hls(image, eps=1e-8)[source]#
Convert an RGB image to HLS.
The image data is assumed to be in the range of (0, 1).
- Convention:
Channels are H, L, S at axis -3. Hue is measured in radians in [0, 2π), unlike OpenCV, which uses degrees (halved for 8-bit images).
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) – bias added to the chroma and lightness denominators before dividing. The zero denominators themselves are handled by a safe-substitution guard, soepsis not what keeps the result finite andeps=0is well defined. Default:1e-8
- Return type:
- 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).
- Convention:
Expects H, L, S channels at axis -3 with hue in radians.
- Parameters:
image (
Tensor) – HLS image to be converted to RGB with shape \((*, 3, H, W)\).- Return type:
- 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.
See the Convention block on
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.
See the Convention block on
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:
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> rgb = HlsToRgb() >>> output = rgb(input) # 2x3x4x5