Color conversion#

Conversions between color spaces, on float image tensors of shape \((*, C, H, W)\) with values in \([0, 1]\). Every conversion exists as a function and as an nn.Module; each page below documents one color scheme.

All functions#

rgb_to_grayscale

Convert a RGB image to grayscale version of image.

bgr_to_grayscale

Convert a BGR image to grayscale.

grayscale_to_rgb

Convert a grayscale image to RGB version of image.

rgb_to_bgr

Convert a RGB image to BGR.

bgr_to_rgb

Convert a BGR image to RGB.

rgb_to_rgb255

Convert an image from RGB to RGB [0, 255] for visualization purposes.

rgb255_to_rgb

Convert an image from RGB [0, 255] to RGB for visualization purposes.

rgb255_to_normals

Convert an image from RGB [0, 255] to surface normals for visualization purposes.

normals_to_rgb255

Convert surface normals to RGB [0, 255] for visualization purposes.

rgb_to_rgba

Convert an image from RGB to RGBA.

bgr_to_rgba

Convert an image from BGR to RGBA.

rgba_to_rgb

Convert an image from RGBA to RGB using alpha compositing.

rgba_to_bgr

Convert an image from RGBA to BGR.

rgb_to_linear_rgb

Convert an sRGB image to linear RGB.

linear_rgb_to_rgb

Convert a linear RGB image to sRGB.

rgb_to_hls

Convert an RGB image to HLS.

hls_to_rgb

Convert a HLS image to RGB.

rgb_to_hsv

Convert an image from RGB to HSV.

hsv_to_rgb

Convert an image from HSV to RGB.

rgb_to_lab

Convert a RGB image to Lab.

lab_to_rgb

Convert a Lab image to RGB.

rgb_to_luv

Convert a RGB image to Luv.

luv_to_rgb

Convert a Luv image to RGB.

rgb_to_xyz

Convert a RGB image to XYZ.

xyz_to_rgb

Convert a XYZ image to RGB.

rgb_to_ycbcr

Convert an RGB image to YCbCr.

ycbcr_to_rgb

Convert an YCbCr image to RGB.

rgb_to_yuv

Convert an RGB image to YUV.

yuv_to_rgb

Convert an YUV image to RGB.

rgb_to_yuv420

Convert an RGB image to YUV 420 (subsampled).

yuv420_to_rgb

Convert an YUV420 image to RGB.

rgb_to_yuv422

Convert an RGB image to YUV 422 (subsampled).

yuv422_to_rgb

Convert an YUV422 image to RGB.

rgb_to_raw

Convert a RGB image to RAW version of image with the specified color filter array.

raw_to_rgb

Convert a raw bayer image to RGB version of image.

raw_to_rgb_2x2_downscaled

Convert the raw bayer image to RGB version of it and resize width and height by half.