CIE XYZ#
Tip
Learn more: https://en.wikipedia.org/wiki/CIE_1931_color_space
Note
rgb_to_xyz() takes linear RGB: convert an sRGB image with rgb_to_linear_rgb() first, and the result of
xyz_to_rgb() back with linear_rgb_to_rgb(). rgb_to_lab() and rgb_to_luv() take sRGB.
Functions#
- kornia.color.rgb_to_xyz(image)[source]#
Convert a linear RGB image to XYZ.
xyz = rgb_to_xyz(image)converts a(*, 3, H, W)linear RGB image to CIE XYZ with the sRGB primaries and the D65 white point. It does not remove the sRGB curve: for an sRGB image, pass the result ofrgb_to_linear_rgb().
- Convention:
A matrix transform of the channels at axis -3. OpenCV’s
COLOR_RGB2XYZdoes the same, and skimagergb2xyzlinearizes its input first.
- Parameters:
image (
Tensor) – linear RGB image with shape(*, 3, H, W).- Return type:
- Returns:
XYZ image with shape
(*, 3, H, W).
See also
xyz_to_rgb(): the inverse.rgb_to_linear_rgb(): the step before this one.RgbToXyz: the module form.
Example
>>> input = torch.rand(2, 3, 4, 5) >>> output = rgb_to_xyz(input) # 2x3x4x5
- kornia.color.xyz_to_rgb(image)[source]#
Convert an XYZ image to linear RGB.
rgb = xyz_to_rgb(image)converts a(*, 3, H, W)CIE XYZ image with the D65 white point to linear RGB with the sRGB primaries. For an sRGB result, applylinear_rgb_to_rgb()to it.- Convention:
A matrix transform of the channels at axis -3. The result is not clipped.
- Parameters:
image (
Tensor) – XYZ image with shape(*, 3, H, W).- Return type:
- Returns:
Linear RGB image with shape
(*, 3, H, W).
See also
rgb_to_xyz(): the inverse.linear_rgb_to_rgb(): the step after this one.XyzToRgb: the module form.
Example
>>> input = torch.rand(2, 3, 4, 5) >>> output = xyz_to_rgb(input) # 2x3x4x5
Modules#
- class kornia.color.RgbToXyz(*args, **kwargs)[source]#
Convert an image from linear RGB to XYZ (module form).
out = RgbToXyz()(image)isrgb_to_xyz().- Convention:
See the convention block of
rgb_to_xyz().
- Shape:
image:
(*, 3, H, W)output:
(*, 3, H, W)
See also
rgb_to_xyz(): the one-call form.XyzToRgb: the inverse.RgbToLinearRgb: removes the sRGB curve before this module.
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> xyz = RgbToXyz() >>> output = xyz(input) # 2x3x4x5
References
[1] https://docs.opencv.org/4.0.1/de/d25/imgproc_color_conversions.html
- class kornia.color.XyzToRgb(*args, **kwargs)[source]#
Convert an image from XYZ to linear RGB (module form).
out = XyzToRgb()(image)isxyz_to_rgb().- Convention:
See the convention block of
xyz_to_rgb().
- Shape:
image:
(*, 3, H, W)output:
(*, 3, H, W)
See also
xyz_to_rgb(): the one-call form.RgbToXyz: the inverse.LinearRgbToRgb: applies the sRGB curve after this module.
Examples
>>> input = torch.rand(2, 3, 4, 5) >>> rgb = XyzToRgb() >>> output = rgb(input) # 2x3x4x5
References
[1] https://docs.opencv.org/4.0.1/de/d25/imgproc_color_conversions.html