HSV#
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_hsv(image, eps=1e-8)[source]#
Convert an image from RGB to HSV.
hsv = rgb_to_hsv(image)converts a(*, 3, H, W)RGB image in \([0, 1]\) to hue, saturation and value.
- Convention:
Channels are H, S, V at axis -3. Hue is in radians in \([0, 2\pi)\), unlike OpenCV, which uses degrees (halved for 8-bit images), and grayscale pixels have hue zero. S and V are in \([0, 1]\).
- Parameters:
- Return type:
- Returns:
HSV image with shape
(*, 3, H, W).
Note
See a working example here.
See also
hsv_to_rgb(): the inverse.RgbToHsv: the module form, withepsstored.
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.
rgb = hsv_to_rgb(image)converts a(*, 3, H, W)image of hue in radians, saturation in \([0, 1]\) and value in \([0, 1]\) to RGB.- Convention:
Channels are H, S, V at axis -3. Hue wraps modulo 2π. The result is not clipped, so saturation or value outside \([0, 1]\) can give RGB values outside it.
- Parameters:
image (
Tensor) – HSV image with shape(*, 3, H, W).- Return type:
- Returns:
RGB image with shape
(*, 3, H, W).
See also
rgb_to_hsv(): the inverse.HsvToRgb: the module form.
Example
>>> input = torch.rand(2, 3, 4, 5) >>> output = hsv_to_rgb(input) # 2x3x4x5
Modules#
- class kornia.color.RgbToHsv(eps=1e-8)[source]#
Convert an image from RGB to HSV (module form).
hsv = RgbToHsv(eps)storeseps, andout = hsv(image)isrgb_to_hsv()with it.- Convention:
See the convention block of
rgb_to_hsv().
- Parameters:
eps (
float, optional) – added to V in the saturation denominator where V is non-zero. Default:1e-8
- Shape:
image:
(*, 3, H, W)output:
(*, 3, H, W)
See also
rgb_to_hsv(): the one-call form.HsvToRgb: the inverse.
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 (module form).
out = HsvToRgb()(image)ishsv_to_rgb().- Convention:
See the convention block of
hsv_to_rgb().
- Shape:
image:
(*, 3, H, W)output:
(*, 3, H, W)
See also
hsv_to_rgb(): the one-call form.RgbToHsv: the inverse.
Example
>>> input = torch.rand(2, 3, 4, 5) >>> rgb = HsvToRgb() >>> output = rgb(input) # 2x3x4x5