Color conversion#
Conversions between color spaces, on float image tensors of shape (*, C, H, W). Every conversion except
rgb_to_y() exists as a function and as an nn.Module; each page below documents one color scheme.
All functions#
Convert an RGB image to grayscale. |
|
Convert a BGR image to grayscale. |
|
Convert a grayscale image to RGB. |
|
Convert an RGB image to BGR. |
|
Convert a BGR image to RGB. |
|
Scale an RGB image from [0, 1] to [0, 255]. |
|
Scale an RGB image from [0, 255] to [0, 1]. |
|
Map an RGB image in [0, 255] to unit surface normals. |
|
Map surface normals in [-1, 1] to RGB in [0, 255]. |
|
Convert an RGB image to RGBA by appending an alpha channel. |
|
Convert a BGR image to RGBA, with the color channels in RGB order. |
|
Convert an RGBA image to RGB by compositing it over a background. |
|
Convert an RGBA image to BGR by compositing it over white. |
|
Convert an sRGB image to linear RGB. |
|
Convert a linear RGB image to sRGB. |
|
Convert an RGB image to HLS. |
|
Convert an HLS image to RGB. |
|
Convert an image from RGB to HSV. |
|
Convert an image from HSV to RGB. |
|
Convert an sRGB image to Lab. |
|
Convert a Lab image to sRGB. |
|
Convert an sRGB image to Luv. |
|
Convert a Luv image to sRGB. |
|
Convert a linear RGB image to XYZ. |
|
Convert an XYZ image to linear RGB. |
|
Convert an RGB image to full-range YCbCr. |
|
Convert an RGB image to the Y channel of YCbCr. |
|
Convert a full-range YCbCr image to RGB. |
|
Convert an RGB image to YUV. |
|
Convert a YUV image to RGB. |
|
Convert an RGB image to YUV 4:2:0 planes. |
|
Convert YUV 4:2:0 planes to RGB. |
|
Convert an RGB image to YUV 4:2:2 planes. |
|
Convert YUV 4:2:2 planes to RGB. |
|
Sample an RGB image into a Bayer raw image. |
|
Demosaic a Bayer raw image to RGB. |
|
Convert a Bayer raw image to RGB at half the height and width. |