HSV#

Note

Hue is returned in radians in \([0, 2\pi)\); see Conventions & Pitfalls.

Functions#

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

Convert an image from RGB to HSV.

_images/rgb_to_hsv.png

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

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

  • eps (float, optional) – scalar to enforce numarical stability. Default: 1e-8

Return type:

Tensor

Returns:

HSV version of the image with shape of \((*, 3, H, W)\). The H channel values are in the range 0..2pi. S and V are in the range 0..1.

Note

See a working example here.

Example

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

Convert an image from HSV to RGB.

The H channel values are assumed to be in the range 0..2pi. S and V are in the range 0..1.

Parameters:

image (Tensor) – HSV Image to be converted to HSV with shape of \((*, 3, H, W)\).

Return type:

Tensor

Returns:

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

Example

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

Modules#

class kornia.color.RgbToHsv(eps=1e-6)[source]#

Convert an image from RGB to HSV.

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

Parameters:

eps (float, optional) – scalar to enforce numarical stability. Default: 1e-6

Returns:

HSV version of the image.

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

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

Example

>>> input = torch.rand(2, 3, 4, 5)
>>> hsv = RgbToHsv()
>>> output = hsv(input)  # 2x3x4x5
class kornia.color.HsvToRgb(*args, **kwargs)[source]#

Convert an image from HSV to RGB.

H channel values are assumed to be in the range 0..2pi. S and V are in the range 0..1.

Returns:

RGB version of the image.

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

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

Example

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