OpenCV: Color space processing

| OpenCV 3.4.2 Open Source Computer Vision

Enumerations | Functions
Color space processing
Core functionality » OpenGL interoperability » CUDA-accelerated Computer Vision » Image Processing

## Enumerations
enum | cv::cuda::AlphaCompTypes { cv::cuda::ALPHA_OVER, cv::cuda::ALPHA_IN, cv::cuda::ALPHA_OUT, cv::cuda::ALPHA_ATOP, cv::cuda::ALPHA_XOR, cv::cuda::ALPHA_PLUS, cv::cuda::ALPHA_OVER_PREMUL, cv::cuda::ALPHA_IN_PREMUL, cv::cuda::ALPHA_OUT_PREMUL, cv::cuda::ALPHA_ATOP_PREMUL, cv::cuda::ALPHA_XOR_PREMUL, cv::cuda::ALPHA_PLUS_PREMUL, cv::cuda::ALPHA_PREMUL }
enum | cv::cuda::DemosaicTypes { cv::cuda::COLOR_BayerBG2BGR_MHT = 256, cv::cuda::COLOR_BayerGB2BGR_MHT = 257, cv::cuda::COLOR_BayerRG2BGR_MHT = 258, cv::cuda::COLOR_BayerGR2BGR_MHT = 259, cv::cuda::COLOR_BayerBG2RGB_MHT = COLOR_BayerRG2BGR_MHT, cv::cuda::COLOR_BayerGB2RGB_MHT = COLOR_BayerGR2BGR_MHT, cv::cuda::COLOR_BayerRG2RGB_MHT = COLOR_BayerBG2BGR_MHT, cv::cuda::COLOR_BayerGR2RGB_MHT = COLOR_BayerGB2BGR_MHT, cv::cuda::COLOR_BayerBG2GRAY_MHT = 260, cv::cuda::COLOR_BayerGB2GRAY_MHT = 261, cv::cuda::COLOR_BayerRG2GRAY_MHT = 262, cv::cuda::COLOR_BayerGR2GRAY_MHT = 263 }

## Functions
void | cv::cuda::alphaComp (InputArray img1, InputArray img2, OutputArray dst, int alpha_op, Stream &stream=Stream::Null())
| Composites two images using alpha opacity values contained in each image. More...
void | cv::cuda::cvtColor (InputArray src, OutputArray dst, int code, int dcn=0, Stream &stream=Stream::Null())
| Converts an image from one color space to another. More...
void | cv::cuda::demosaicing (InputArray src, OutputArray dst, int code, int dcn=-1, Stream &stream=Stream::Null())
| Converts an image from Bayer pattern to RGB or grayscale. More...
void | cv::cuda::gammaCorrection (InputArray src, OutputArray dst, bool forward=true, Stream &stream=Stream::Null())
| Routines for correcting image color gamma. More...
void | cv::cuda::swapChannels (InputOutputArray image, const int dstOrder[4], Stream &stream=Stream::Null())
| Exchanges the color channels of an image in-place. More...

## Detailed Description

## Enumeration Type Documentation

## ◆ AlphaCompTypes

enum cv::cuda::AlphaCompTypes

Enumerator
ALPHA_OVER |
ALPHA_IN |
ALPHA_OUT |
ALPHA_ATOP |
ALPHA_XOR |
ALPHA_PLUS |
ALPHA_OVER_PREMUL |
ALPHA_IN_PREMUL |
ALPHA_OUT_PREMUL |
ALPHA_ATOP_PREMUL |
ALPHA_XOR_PREMUL |
ALPHA_PLUS_PREMUL |
ALPHA_PREMUL |

## ◆ DemosaicTypes

enum cv::cuda::DemosaicTypes

Enumerator
COLOR_BayerBG2BGR_MHT | Bayer Demosaicing (Malvar, He, and Cutler)
COLOR_BayerGB2BGR_MHT |
COLOR_BayerRG2BGR_MHT |
COLOR_BayerGR2BGR_MHT |
COLOR_BayerBG2RGB_MHT |
COLOR_BayerGB2RGB_MHT |
COLOR_BayerRG2RGB_MHT |
COLOR_BayerGR2RGB_MHT |
COLOR_BayerBG2GRAY_MHT |
COLOR_BayerGB2GRAY_MHT |
COLOR_BayerRG2GRAY_MHT |
COLOR_BayerGR2GRAY_MHT |

## Function Documentation

## ◆ alphaComp()

void cv::cuda::alphaComp | ( | InputArray | img1,
|  | InputArray | img2,
|  | OutputArray | dst,
|  | int | alpha_op,
|  | Stream & | stream = `Stream::Null()`
| ) |  |

Composites two images using alpha opacity values contained in each image.

Parameters

  img1 | First image. Supports CV_8UC4 , CV_16UC4 , CV_32SC4 and CV_32FC4 types.
  img2 | Second image. Must have the same size and the same type as img1 .
  dst | Destination image.
  alpha_op | Flag specifying the alpha-blending operation: ALPHA_OVER ALPHA_IN ALPHA_OUT ALPHA_ATOP ALPHA_XOR ALPHA_PLUS ALPHA_OVER_PREMUL ALPHA_IN_PREMUL ALPHA_OUT_PREMUL ALPHA_ATOP_PREMUL ALPHA_XOR_PREMUL ALPHA_PLUS_PREMUL ALPHA_PREMUL
  stream | Stream for the asynchronous version.

Note
  - An example demonstrating the use of alphaComp can be found at opencv_source_code/samples/gpu/alpha_comp.cpp

## ◆ cvtColor()

void cv::cuda::cvtColor | ( | InputArray | src,
|  | OutputArray | dst,
|  | int | code,
|  | int | dcn = `0`,
|  | Stream & | stream = `Stream::Null()`
| ) |  |

Converts an image from one color space to another.

Parameters

  src | Source image with CV_8U , CV_16U , or CV_32F depth and 1, 3, or 4 channels.
  dst | Destination image.
  code | Color space conversion code. For details, see cvtColor .
  dcn | Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from src and the code .
  stream | Stream for the asynchronous version.

3-channel color spaces (like HSV, XYZ, and so on) can be stored in a 4-channel image for better performance.

See also
  cvtColor

## ◆ demosaicing()

void cv::cuda::demosaicing | ( | InputArray | src,
|  | OutputArray | dst,
|  | int | code,
|  | int | dcn = `-1`,
|  | Stream & | stream = `Stream::Null()`
| ) |  |

Converts an image from Bayer pattern to RGB or grayscale.

Parameters

  src | Source image (8-bit or 16-bit single channel).
  dst | Destination image.
  code | Color space conversion code (see the description below).
  dcn | Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from src and the code .
  stream | Stream for the asynchronous version.

The function can do the following transformations:

- Demosaicing using bilinear interpolation

  > - COLOR_BayerBG2GRAY , COLOR_BayerGB2GRAY , COLOR_BayerRG2GRAY , COLOR_BayerGR2GRAY > - COLOR_BayerBG2BGR , COLOR_BayerGB2BGR , COLOR_BayerRG2BGR , COLOR_BayerGR2BGR

- Demosaicing using Malvar-He-Cutler algorithm ([MHT2011])

  > - COLOR_BayerBG2GRAY_MHT , COLOR_BayerGB2GRAY_MHT , COLOR_BayerRG2GRAY_MHT , > COLOR_BayerGR2GRAY_MHT > - COLOR_BayerBG2BGR_MHT , COLOR_BayerGB2BGR_MHT , COLOR_BayerRG2BGR_MHT , > COLOR_BayerGR2BGR_MHT

See also
  cvtColor

## ◆ gammaCorrection()

void cv::cuda::gammaCorrection | ( | InputArray | src,
|  | OutputArray | dst,
|  | bool | forward = `true`,
|  | Stream & | stream = `Stream::Null()`
| ) |  |

Routines for correcting image color gamma.

Parameters

  src | Source image (3- or 4-channel 8 bit).
  dst | Destination image.
  forward | true for forward gamma correction or false for inverse gamma correction.
  stream | Stream for the asynchronous version.

## ◆ swapChannels()

void cv::cuda::swapChannels | ( | InputOutputArray | image,
|  | const int | dstOrder[4],
|  | Stream & | stream = `Stream::Null()`
| ) |  |

Exchanges the color channels of an image in-place.

Parameters

  image | Source image. Supports only CV_8UC4 type.
  dstOrder | Integer array describing how channel values are permutated. The n-th entry of the array contains the number of the channel that is stored in the n-th channel of the output image. E.g. Given an RGBA image, aDstOrder = [3,2,1,0] converts this to ABGR channel order.
  stream | Stream for the asynchronous version.

The methods support arbitrary permutations of the original channels, including replication.