Back to Jetson Inference

Jetson Inference: Color Conversion

docs/html/group__colorspace.html

latest20.7 KB
Original Source

| | Jetson Inference

DNN Vision Library |

Functions

Color Conversion Utilities Library (jetson-utils) » CUDA

Colorspace conversion functions for various YUV formats, RGB, BGR, Bayer, and grayscale. More...

|

Functions

| | cudaError_t | cudaConvertColor (void *input, imageFormat inputFormat, void *output, imageFormat outputFormat, size_t width, size_t height, const float2 &pixel_range=make_float2(0, 255)) | | | Convert between two image formats using the GPU. More...
| | | | template<typename T_in , typename T_out > | | cudaError_t | cudaConvertColor (T_in *input, T_out *output, size_t width, size_t height, const float2 &pixel_range=make_float2(0, 255)) | | | Convert between to image formats using the GPU. More...
| | |

|

8-bit grayscale to floating-point grayscale (and vice versa)

| |

See alsocudaConvertColor() from cudaColorspace.h for automated format conversion | | cudaError_t | cudaGray8ToGray32 (uint8_t *input, float *output, size_t width, size_t height) | | | Convert uint8 grayscale image into float grayscale. More...
| | | | cudaError_t | cudaGray32ToGray8 (float *input, uint8_t *output, size_t width, size_t height, const float2 &pixelRange=make_float2(0, 255)) | | | Convert float grayscale image into uint8 grayscale. More...
| | |

|

RGB/BGR to 8-bit grayscale

| |

See alsocudaConvertColor() from cudaColorspace.h for automated format conversion | | cudaError_t | cudaRGB8ToGray8 (uchar3 *input, uint8_t *output, size_t width, size_t height, bool swapRedBlue=false) | | | Convert uchar3 RGB/BGR image into uint8 grayscale. More...
| | | | cudaError_t | cudaRGBA8ToGray8 (uchar4 *input, uint8_t *output, size_t width, size_t height, bool swapRedBlue=false) | | | Convert uchar4 RGBA/BGRA image into uint8 grayscale. More...
| | | | cudaError_t | cudaRGB32ToGray8 (float3 *input, uint8_t *output, size_t width, size_t height, bool swapRedBlue=false, const float2 &pixelRange=make_float2(0, 255)) | | | Convert float3 RGB/BGR image into uint8 grayscale. More...
| | | | cudaError_t | cudaRGBA32ToGray8 (float4 *input, uint8_t *output, size_t width, size_t height, bool swapRedBlue=false, const float2 &pixelRange=make_float2(0, 255)) | | | Convert float4 RGBA/BGRA image into uint8 grayscale. More...
| | |

|

RGB/BGR to floating-point grayscale

| |

See alsocudaConvertColor() from cudaColorspace.h for automated format conversion | | cudaError_t | cudaRGB8ToGray32 (uchar3 *input, float *output, size_t width, size_t height, bool swapRedBlue=false) | | | Convert uchar3 RGB/BGR image into float grayscale. More...
| | | | cudaError_t | cudaRGBA8ToGray32 (uchar4 *input, float *output, size_t width, size_t height, bool swapRedBlue=false) | | | Convert uchar4 RGBA/BGRA image into float grayscale. More...
| | | | cudaError_t | cudaRGB32ToGray32 (float3 *input, float *output, size_t width, size_t height, bool swapRedBlue=false) | | | Convert float3 RGB/BGR image into float grayscale. More...
| | | | cudaError_t | cudaRGBA32ToGray32 (float4 *input, float *output, size_t width, size_t height, bool swapRedBlue=false) | | | Convert float4 RGB/BGR image into float grayscale. More...
| | |

|

8-bit grayscale to RGB/BGR

| |

See alsocudaConvertColor() from cudaColorspace.h for automated format conversion | | cudaError_t | cudaGray8ToRGB8 (uint8_t *input, uchar3 *output, size_t width, size_t height) | | | Convert uint8 grayscale image into uchar3 RGB/BGR. More...
| | | | cudaError_t | cudaGray8ToRGBA8 (uint8_t *input, uchar4 *output, size_t width, size_t height) | | | Convert uint8 grayscale image into uchar4 RGB/BGR. More...
| | | | cudaError_t | cudaGray8ToRGB32 (uint8_t *input, float3 *output, size_t width, size_t height) | | | Convert uint8 grayscale image into float3 RGB/BGR. More...
| | | | cudaError_t | cudaGray8ToRGBA32 (uint8_t *input, float4 *output, size_t width, size_t height) | | | Convert uint8 grayscale image into float4 RGB/BGR. More...
| | |

|

Floating-point grayscale to RGB/BGR

| |

See alsocudaConvertColor() from cudaColorspace.h for automated format conversion | | cudaError_t | cudaGray32ToRGB8 (float *input, uchar3 *output, size_t width, size_t height, const float2 &pixelRange=make_float2(0, 255)) | | | Convert float grayscale image into uchar3 RGB/BGR. More...
| | | | cudaError_t | cudaGray32ToRGBA8 (float *input, uchar4 *output, size_t width, size_t height, const float2 &pixelRange=make_float2(0, 255)) | | | Convert float grayscale image into uchar4 RGB/BGR. More...
| | | | cudaError_t | cudaGray32ToRGB32 (float *input, float3 *output, size_t width, size_t height) | | | Convert float grayscale image into float3 RGB/BGR. More...
| | | | cudaError_t | cudaGray32ToRGBA32 (float *input, float4 *output, size_t width, size_t height) | | | Convert float grayscale image into float4 RGB/BGR. More...
| | |

Detailed Description

Colorspace conversion functions for various YUV formats, RGB, BGR, Bayer, and grayscale.

See alsocudaConvertColor for automated format conversion. cudaYUV.h for the YUV functions.

Function Documentation

cudaConvertColor() [1/2]

template<typename T_in , typename T_out >

| cudaError_t cudaConvertColor | ( | T_in * | input, | | | | T_out * | output, | | | | size_t | width, | | | | size_t | height, | | | | const float2 & | pixel_range = make_float2(0,255) | | | ) | | |

Convert between to image formats using the GPU.

This templated overload of cudaConvertColor() supports uchar3 (IMAGE_RGB8), uchar4 (IMAGE_RGBA8), float3 (IMAGE_RGB32F), and float4 (IMAGE_RGBA32F).

To convert to/from other formats such as YUV, grayscale, and BGR/BGRA, see the other version of cudaConvertColor() that uses explicity imageFormat enums.

Parameters

| input | CUDA device pointer to the input image | | output | CUDA device pointer to the input image | | width | width of the input and output images (in pixels) | | height | height of the input and output images (in pixels) | | pixel_range | for floating-point to 8-bit conversions, specifies the range of pixel intensities in the input image that get normalized to [0,255]. The default input range is [0,255], and as such no normalization occurs. Other common pixel ranges include [0,1] and [-1,1], and these pixel values would be re-scaled for [0,255] output. Note that this parameter is only used for float-to-uchar conversions where the data is downcast (for example, IMAGE_RGB32F to IMAGE_RGB8). |

cudaConvertColor() [2/2]

| cudaError_t cudaConvertColor | ( | void * | input, | | | | imageFormat | inputFormat, | | | | void * | output, | | | | imageFormat | outputFormat, | | | | size_t | width, | | | | size_t | height, | | | | const float2 & | pixel_range = make_float2(0, 255) | | | ) | | |

Convert between two image formats using the GPU.

This function supports various conversions between RGB/RGBA, BGR/BGRA, Bayer, grayscale, and YUV. In addition to converting between the previously listed colorspaces, you can also change the number of channels or data format (for example, IMAGE_RGB8 to IMAGE_RGBA32F).

For the list of image formats available,

See alsoimageFormat enum.

Limitations and unsupported conversions include:

- The YUV formats don't support BGR/BGRA or grayscale (RGB/RGBA only)
- YUV NV12, YUYV, YVYU, and UYVY can only be converted to RGB/RGBA (not from)
- Bayer formats can only be converted to RGB8 (`uchar3`) and RGBA8 (`uchar4`)

Parameters

| input | CUDA device pointer to the input image | | inputFormat | format enum of the input image | | output | CUDA device pointer to the input image | | outputFormat | format enum of the output image | | width | width of the input and output images (in pixels) | | height | height of the input and output images (in pixels) | | pixel_range | for floating-point to 8-bit conversions, specifies the range of pixel intensities in the input image that get normalized to [0,255]. The default input range is [0,255], and as such no normalization occurs. Other common pixel ranges include [0,1] and [-1,1], and these pixel values would be re-scaled for [0,255] output. Note that this parameter is only used for float-to-uchar conversions where the data is downcast (for example, IMAGE_RGB32F to IMAGE_RGB8). |

cudaGray32ToGray8()

| cudaError_t cudaGray32ToGray8 | ( | float * | input, | | | | uint8_t * | output, | | | | size_t | width, | | | | size_t | height, | | | | const float2 & | pixelRange = make_float2(0, 255) | | | ) | | |

Convert float grayscale image into uint8 grayscale.

Parameters

| pixelRange | specifies the floating-point pixel value range of the input image, which is used to rescale the fixed-point pixel outputs to [0,255]. The default input range is [0,255], where no rescaling occurs. Other common input ranges are [-1, 1] or [0,1]. |

cudaGray32ToRGB32()

| cudaError_t cudaGray32ToRGB32 | ( | float * | input, | | | | float3 * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert float grayscale image into float3 RGB/BGR.

cudaGray32ToRGB8()

| cudaError_t cudaGray32ToRGB8 | ( | float * | input, | | | | uchar3 * | output, | | | | size_t | width, | | | | size_t | height, | | | | const float2 & | pixelRange = make_float2(0, 255) | | | ) | | |

Convert float grayscale image into uchar3 RGB/BGR.

Parameters

| pixelRange | specifies the floating-point pixel value range of the input image, | | pixelRange | specifies the floating-point pixel value range of the input image, which is used to rescale the fixed-point pixel outputs to [0,255]. The default input range is [0,255], where no rescaling occurs. Other common input ranges are [-1, 1] or [0,1]. |

cudaGray32ToRGBA32()

| cudaError_t cudaGray32ToRGBA32 | ( | float * | input, | | | | float4 * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert float grayscale image into float4 RGB/BGR.

cudaGray32ToRGBA8()

| cudaError_t cudaGray32ToRGBA8 | ( | float * | input, | | | | uchar4 * | output, | | | | size_t | width, | | | | size_t | height, | | | | const float2 & | pixelRange = make_float2(0, 255) | | | ) | | |

Convert float grayscale image into uchar4 RGB/BGR.

Parameters

| pixelRange | specifies the floating-point pixel value range of the input image, which is used to rescale the fixed-point pixel outputs to [0,255]. The default input range is [0,255], where no rescaling occurs. Other common input ranges are [-1, 1] or [0,1]. |

cudaGray8ToGray32()

| cudaError_t cudaGray8ToGray32 | ( | uint8_t * | input, | | | | float * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert uint8 grayscale image into float grayscale.

cudaGray8ToRGB32()

| cudaError_t cudaGray8ToRGB32 | ( | uint8_t * | input, | | | | float3 * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert uint8 grayscale image into float3 RGB/BGR.

cudaGray8ToRGB8()

| cudaError_t cudaGray8ToRGB8 | ( | uint8_t * | input, | | | | uchar3 * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert uint8 grayscale image into uchar3 RGB/BGR.

cudaGray8ToRGBA32()

| cudaError_t cudaGray8ToRGBA32 | ( | uint8_t * | input, | | | | float4 * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert uint8 grayscale image into float4 RGB/BGR.

cudaGray8ToRGBA8()

| cudaError_t cudaGray8ToRGBA8 | ( | uint8_t * | input, | | | | uchar4 * | output, | | | | size_t | width, | | | | size_t | height | | | ) | | |

Convert uint8 grayscale image into uchar4 RGB/BGR.

cudaRGB32ToGray32()

| cudaError_t cudaRGB32ToGray32 | ( | float3 * | input, | | | | float * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false | | | ) | | |

Convert float3 RGB/BGR image into float grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. |

cudaRGB32ToGray8()

| cudaError_t cudaRGB32ToGray8 | ( | float3 * | input, | | | | uint8_t * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false, | | | | const float2 & | pixelRange = make_float2(0, 255) | | | ) | | |

Convert float3 RGB/BGR image into uint8 grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. | | pixelRange | specifies the floating-point pixel value range of the input image, which is used to rescale the fixed-point pixel outputs to [0,255]. The default input range is [0,255], where no rescaling occurs. Other common input ranges are [-1, 1] or [0,1]. |

cudaRGB8ToGray32()

| cudaError_t cudaRGB8ToGray32 | ( | uchar3 * | input, | | | | float * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false | | | ) | | |

Convert uchar3 RGB/BGR image into float grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. |

cudaRGB8ToGray8()

| cudaError_t cudaRGB8ToGray8 | ( | uchar3 * | input, | | | | uint8_t * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false | | | ) | | |

Convert uchar3 RGB/BGR image into uint8 grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. |

cudaRGBA32ToGray32()

| cudaError_t cudaRGBA32ToGray32 | ( | float4 * | input, | | | | float * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false | | | ) | | |

Convert float4 RGB/BGR image into float grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. |

cudaRGBA32ToGray8()

| cudaError_t cudaRGBA32ToGray8 | ( | float4 * | input, | | | | uint8_t * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false, | | | | const float2 & | pixelRange = make_float2(0, 255) | | | ) | | |

Convert float4 RGBA/BGRA image into uint8 grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. | | pixelRange | specifies the floating-point pixel value range of the input image, which is used to rescale the fixed-point pixel outputs to [0,255]. The default input range is [0,255], where no rescaling occurs. Other common input ranges are [-1, 1] or [0,1]. |

cudaRGBA8ToGray32()

| cudaError_t cudaRGBA8ToGray32 | ( | uchar4 * | input, | | | | float * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false | | | ) | | |

Convert uchar4 RGBA/BGRA image into float grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. |

cudaRGBA8ToGray8()

| cudaError_t cudaRGBA8ToGray8 | ( | uchar4 * | input, | | | | uint8_t * | output, | | | | size_t | width, | | | | size_t | height, | | | | bool | swapRedBlue = false | | | ) | | |

Convert uchar4 RGBA/BGRA image into uint8 grayscale.

Parameters

| swapRedBlue | if true, swap the input's red and blue channels. The default is false, and the channels will remain the same. |

  • Generated on Tue Mar 28 2023 14:27:58 for Jetson Inference by 1.8.17