Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

Functions for BGR-24 image conversions. More...

Functions

SIMD_API void SimdBgrToBayer (const uint8_t *bgr, size_t width, size_t height, size_t bgrStride, uint8_t *bayer, size_t bayerStride, SimdPixelFormatType bayerFormat)
 Converts a 24-bit BGR image to a single-channel 8-bit Bayer mosaic image. More...
 
SIMD_API void SimdBgrToBgra (const uint8_t *bgr, size_t width, size_t height, size_t bgrStride, uint8_t *bgra, size_t bgraStride, uint8_t alpha)
 Converts a 24-bit BGR image to a 32-bit BGRA image with constant alpha. More...
 
SIMD_API void SimdBgrToGray (const uint8_t *bgr, size_t width, size_t height, size_t bgrStride, uint8_t *gray, size_t grayStride)
 Converts a 24-bit BGR image to an 8-bit gray image. More...
 
SIMD_API void SimdBgrToHsl (const uint8_t *bgr, size_t width, size_t height, size_t bgrStride, uint8_t *hsl, size_t hslStride)
 Converts a 24-bit BGR image to a 24-bit HSL (Hue, Saturation, Lightness) image. More...
 
SIMD_API void SimdBgrToHsv (const uint8_t *bgr, size_t width, size_t height, size_t bgrStride, uint8_t *hsv, size_t hsvStride)
 Converts a 24-bit BGR image to a 24-bit HSV (Hue, Saturation, Value) image. More...
 
SIMD_API void SimdBgrToLab (const uint8_t *bgr, size_t bgrStride, size_t width, size_t height, uint8_t *lab, size_t labStride)
 Converts a 24-bit BGR image to a 24-bit CIELAB image. More...
 
SIMD_API void SimdBgrToRgb (const uint8_t *bgr, size_t width, size_t height, size_t bgrStride, uint8_t *rgb, size_t rgbStride)
 Swaps blue and red channels in a 24-bit image. More...
 
SIMD_API void SimdBgrToYuv420pV2 (const uint8_t *bgr, size_t bgrStride, size_t width, size_t height, uint8_t *y, size_t yStride, uint8_t *u, size_t uStride, uint8_t *v, size_t vStride, SimdYuvType yuvType)
 Converts a 24-bit BGR image to planar YUV420P. More...
 
SIMD_API void SimdBgrToYuv422pV2 (const uint8_t *bgr, size_t bgrStride, size_t width, size_t height, uint8_t *y, size_t yStride, uint8_t *u, size_t uStride, uint8_t *v, size_t vStride, SimdYuvType yuvType)
 Converts a 24-bit BGR image to planar YUV422P. More...
 
SIMD_API void SimdBgrToYuv444pV2 (const uint8_t *bgr, size_t bgrStride, size_t width, size_t height, uint8_t *y, size_t yStride, uint8_t *u, size_t uStride, uint8_t *v, size_t vStride, SimdYuvType yuvType)
 Converts a 24-bit BGR image to planar YUV444P. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToBayer (const View< A > &bgr, View< A > &bayer)
 Converts a 24-bit BGR image to an 8-bit Bayer image by sub-sampling color channels. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToBgra (const View< A > &bgr, View< A > &bgra, uint8_t alpha=0xFF)
 Converts a 24-bit BGR image to a 32-bit BGRA image with constant alpha. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToGray (const View< A > &bgr, View< A > &gray)
 Converts a 24-bit BGR image to an 8-bit grayscale image. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToHsl (const View< A > &bgr, View< A > &hsl)
 Converts a 24-bit BGR image to a 24-bit HSL (Hue, Saturation, Lightness) image. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToHsv (const View< A > &bgr, View< A > &hsv)
 Converts a 24-bit BGR image to a 24-bit HSV (Hue, Saturation, Value) image. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToLab (const View< A > &bgr, View< A > &lab)
 Converts a 24-bit BGR image to a 24-bit CIELAB image. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToRgb (const View< A > &bgr, View< A > &rgb)
 Converts a 24-bit BGR image to a 24-bit RGB image by swapping the Red and Blue channels. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToRgba (const View< A > &bgr, View< A > &rgba, uint8_t alpha=0xFF)
 Converts a 24-bit BGR image to a 32-bit RGBA image by swapping the Red and Blue channels and adding constant alpha. More...
 
template<template< class > class A>
SIMD_INLINE void BgrToYuv420p (const View< A > &bgr, View< A > &y, View< A > &u, View< A > &v, SimdYuvType yuvType=SimdYuvBt601)
 Converts a 24-bit BGR image to planar YUV420P (4:2:0). More...
 
template<template< class > class A>
SIMD_INLINE void BgrToYuv422p (const View< A > &bgr, View< A > &y, View< A > &u, View< A > &v, SimdYuvType yuvType=SimdYuvBt601)
 Converts a 24-bit BGR image to planar YUV422P (4:2:2). More...
 
template<template< class > class A>
SIMD_INLINE void BgrToYuv444p (const View< A > &bgr, View< A > &y, View< A > &u, View< A > &v, SimdYuvType yuvType=SimdYuvBt601)
 Converts a 24-bit BGR image to planar YUV444P (4:4:4). More...
 

Detailed Description

Functions for BGR-24 image conversions.

Function Documentation

◆ SimdBgrToBayer()

void SimdBgrToBayer ( const uint8_t *  bgr,
size_t  width,
size_t  height,
size_t  bgrStride,
uint8_t *  bayer,
size_t  bayerStride,
SimdPixelFormatType  bayerFormat 
)

Converts a 24-bit BGR image to a single-channel 8-bit Bayer mosaic image.

For each output pixel only one source color component (B, G or R) is selected according to bayerFormat and its position inside a 2x2 Bayer pattern tile. Input and output images must have the same width and height. The width and the height must be even.

Note
This function has a C++ wrapper Simd::BgrToBayer(const View<A>& bgr, View<A>& bayer).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]width- an image width.
[in]height- an image height.
[in]bgrStride- a row size of the bgr image.
[out]bayer- a pointer to pixels data of output 8-bit Bayer image.
[in]bayerStride- a row size of the bayer image.
[in]bayerFormat- a format of the output bayer image. It can be SimdPixelFormatBayerGrbg, SimdPixelFormatBayerGbrg, SimdPixelFormatBayerRggb or SimdPixelFormatBayerBggr.

◆ SimdBgrToBgra()

void SimdBgrToBgra ( const uint8_t *  bgr,
size_t  width,
size_t  height,
size_t  bgrStride,
uint8_t *  bgra,
size_t  bgraStride,
uint8_t  alpha 
)

Converts a 24-bit BGR image to a 32-bit BGRA image with constant alpha.

For each pixel, B, G and R are copied unchanged and A is set to the alpha parameter. Input and output images must have the same width and height.

Note
This function has a C++ wrapper Simd::BgrToBgra(const View<A>& bgr, View<A>& bgra, uint8_t alpha).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]width- an image width.
[in]height- an image height.
[in]bgrStride- a row size of the bgr image.
[out]bgra- a pointer to pixels data of output 32-bit BGRA image.
[in]bgraStride- a row size of the bgra image.
[in]alpha- a value of alpha channel.

◆ SimdBgrToGray()

void SimdBgrToGray ( const uint8_t *  bgr,
size_t  width,
size_t  height,
size_t  bgrStride,
uint8_t *  gray,
size_t  grayStride 
)

Converts a 24-bit BGR image to an 8-bit gray image.

For every pixel:

gray = round(0.114*blue + 0.587*green + 0.299*red).

Input and output images must have the same width and height.

Note
This function has a C++ wrapper Simd::BgrToGray(const View<A>& bgr, View<A>& gray).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]width- an image width.
[in]height- an image height.
[in]bgrStride- a row size of the bgr image.
[out]gray- a pointer to pixels data of output 8-bit gray image.
[in]grayStride- a row size of the gray image.

◆ SimdBgrToHsl()

void SimdBgrToHsl ( const uint8_t *  bgr,
size_t  width,
size_t  height,
size_t  bgrStride,
uint8_t *  hsl,
size_t  hslStride 
)

Converts a 24-bit BGR image to a 24-bit HSL (Hue, Saturation, Lightness) image.

For each output pixel: hsl[0] = hue, hsl[1] = saturation, hsl[2] = lightness. All HSL components are stored as 8-bit values in range [0, 255]. Input and output images must have the same width and height.

Note
This function has a C++ wrapper Simd::BgrToHsl(const View<A>& bgr, View<A>& hsl).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]width- an image width.
[in]height- an image height.
[in]bgrStride- a row size of the bgr image.
[out]hsl- a pointer to pixels data of output 24-bit HSL image.
[in]hslStride- a row size of the hsl image.

◆ SimdBgrToHsv()

void SimdBgrToHsv ( const uint8_t *  bgr,
size_t  width,
size_t  height,
size_t  bgrStride,
uint8_t *  hsv,
size_t  hsvStride 
)

Converts a 24-bit BGR image to a 24-bit HSV (Hue, Saturation, Value) image.

For each output pixel: hsv[0] = hue, hsv[1] = saturation, hsv[2] = value. All HSV components are stored as 8-bit values in range [0, 255]. Input and output images must have the same width and height.

Note
This function has a C++ wrapper Simd::BgrToHsv(const View<A>& bgr, View<A>& hsv).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]width- an image width.
[in]height- an image height.
[in]bgrStride- a row size of the bgr image.
[out]hsv- a pointer to pixels data of output 24-bit HSV image.
[in]hsvStride- a row size of the hsv image.

◆ SimdBgrToLab()

void SimdBgrToLab ( const uint8_t *  bgr,
size_t  bgrStride,
size_t  width,
size_t  height,
uint8_t *  lab,
size_t  labStride 
)

Converts a 24-bit BGR image to a 24-bit CIELAB image.

For each output pixel: lab[0] = L, lab[1] = A, lab[2] = B. All LAB components are stored as 8-bit values (OpenCV-compatible CIELAB encoding). Input and output images must have the same width and height.

Note
This function has a C++ wrapper Simd::BgrToLab(const View<A>& bgr, View<A>& lab).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]bgrStride- a row size of the bgr image.
[in]width- an image width.
[in]height- an image height.
[out]lab- a pointer to pixels data of output 24-bit LAB image.
[in]labStride- a row size of the lab image.

◆ SimdBgrToRgb()

void SimdBgrToRgb ( const uint8_t *  bgr,
size_t  width,
size_t  height,
size_t  bgrStride,
uint8_t *  rgb,
size_t  rgbStride 
)

Swaps blue and red channels in a 24-bit image.

For each output pixel: rgb[0] = bgr[2], rgb[1] = bgr[1], rgb[2] = bgr[0]. Input and output images must have the same width and height.

Note
This function has C++ wrappers: Simd::BgrToRgb(const View<A> & bgr, View<A> & rgb) and Simd::RgbToBgr(const View<A>& rgb, View<A>& bgr).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image (or 24-bit RGB image).
[in]width- an image width.
[in]height- an image height.
[in]bgrStride- a row size of the bgr image.
[out]rgb- a pointer to pixels data of output 24-bit RGB image (or 24-bit BGR image).
[in]rgbStride- a row size of the rgb image.

◆ SimdBgrToYuv420pV2()

void SimdBgrToYuv420pV2 ( const uint8_t *  bgr,
size_t  bgrStride,
size_t  width,
size_t  height,
uint8_t *  y,
size_t  yStride,
uint8_t *  u,
size_t  uStride,
uint8_t *  v,
size_t  vStride,
SimdYuvType  yuvType 
)

Converts a 24-bit BGR image to planar YUV420P.

The input BGR and output Y images must have the same width and height. U and V images are half-sized in both dimensions: uWidth = vWidth = width/2 and uHeight = vHeight = height/2. Image width and height must be even and not less than 2. Y is computed for every source pixel. U and V are computed per each 2x2 source block from averaged B, G and R values.

Note
This function has a C++ wrapper Simd::BgrToYuv420p(const View& bgr, View& y, View& u, View& v, SimdYuvType yuvType = SimdYuvBt601).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]bgrStride- a row size of the BGR image.
[in]width- an image width.
[in]height- an image height.
[out]y- a pointer to pixels data of output 8-bit image with Y color plane.
[in]yStride- a row size of the y image.
[out]u- a pointer to pixels data of output 8-bit image with U color plane.
[in]uStride- a row size of the u image.
[out]v- a pointer to pixels data of output 8-bit image with V color plane.
[in]vStride- a row size of the v image.
[in]yuvType- a type of output YUV image (see description of SimdYuvType).

◆ SimdBgrToYuv422pV2()

void SimdBgrToYuv422pV2 ( const uint8_t *  bgr,
size_t  bgrStride,
size_t  width,
size_t  height,
uint8_t *  y,
size_t  yStride,
uint8_t *  u,
size_t  uStride,
uint8_t *  v,
size_t  vStride,
SimdYuvType  yuvType 
)

Converts a 24-bit BGR image to planar YUV422P.

The input BGR and output Y images must have the same width and height. U and V images are half-sized horizontally: uWidth = vWidth = width/2 and uHeight = vHeight = height. Image width must be even and not less than 2. Y is computed for every source pixel. U and V are computed per each pair of neighboring horizontal pixels from averaged B, G and R values.

Note
This function has a C++ wrapper Simd::BgrToYuv422p(const View& bgr, View& y, View& u, View& v, SimdYuvType yuvType = SimdYuvBt601).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]bgrStride- a row size of the BGR image.
[in]width- an image width.
[in]height- an image height.
[out]y- a pointer to pixels data of output 8-bit image with Y color plane.
[in]yStride- a row size of the y image.
[out]u- a pointer to pixels data of output 8-bit image with U color plane.
[in]uStride- a row size of the u image.
[out]v- a pointer to pixels data of output 8-bit image with V color plane.
[in]vStride- a row size of the v image.
[in]yuvType- a type of output YUV image (see description of SimdYuvType).

◆ SimdBgrToYuv444pV2()

void SimdBgrToYuv444pV2 ( const uint8_t *  bgr,
size_t  bgrStride,
size_t  width,
size_t  height,
uint8_t *  y,
size_t  yStride,
uint8_t *  u,
size_t  uStride,
uint8_t *  v,
size_t  vStride,
SimdYuvType  yuvType 
)

Converts a 24-bit BGR image to planar YUV444P.

The input BGR and output Y, U and V images must have the same width and height. Y, U and V are computed for each source pixel without chroma subsampling.

Note
This function has a C++ wrapper Simd::BgrToYuv444p(const View& bgr, View& y, View& u, View& v, SimdYuvType yuvType = SimdYuvBt601).
Parameters
[in]bgr- a pointer to pixels data of input 24-bit BGR image.
[in]bgrStride- a row size of the BGR image.
[in]width- an image width.
[in]height- an image height.
[out]y- a pointer to pixels data of output 8-bit image with Y color plane.
[in]yStride- a row size of the y image.
[out]u- a pointer to pixels data of output 8-bit image with U color plane.
[in]uStride- a row size of the u image.
[out]v- a pointer to pixels data of output 8-bit image with V color plane.
[in]vStride- a row size of the v image.
[in]yuvType- a type of output YUV image (see description of SimdYuvType).

◆ BgrToBayer()

void BgrToBayer ( const View< A > &  bgr,
View< A > &  bayer 
)

Converts a 24-bit BGR image to an 8-bit Bayer image by sub-sampling color channels.

The function down-samples a full-color 24-bit BGR image to an 8-bit Bayer-patterned image. For each 2x2 block of BGR pixels, exactly one color channel value (Blue, Green, or Red) is selected per output pixel according to the Bayer pattern of the bayer image. Both images must have the same width and height, and both dimensions must be even. The Bayer pattern is taken from the format of the bayer image (View::BayerGrbg, View::BayerGbrg, View::BayerRggb or View::BayerBggr).

Note
This function is a C++ wrapper for function SimdBgrToBayer.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]bayer- an output 8-bit Bayer image.

◆ BgrToBgra()

void BgrToBgra ( const View< A > &  bgr,
View< A > &  bgra,
uint8_t  alpha = 0xFF 
)

Converts a 24-bit BGR image to a 32-bit BGRA image with constant alpha.

The function converts a 24-bit BGR (Blue, Green, Red) image to a 32-bit BGRA (Blue, Green, Red, Alpha) image. For each pixel, Blue, Green and Red are copied unchanged and Alpha is set to the constant value specified by the alpha parameter. Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToBgra.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]bgra- an output 32-bit BGRA image.
[in]alpha- a constant value to fill the alpha channel of every output pixel. It is equal to 0xFF by default.

◆ BgrToGray()

void BgrToGray ( const View< A > &  bgr,
View< A > &  gray 
)

Converts a 24-bit BGR image to an 8-bit grayscale image.

The function converts a 24-bit BGR (Blue, Green, Red) image to an 8-bit grayscale image. The luminance value of each pixel is calculated from the Blue, Green, and Red channels using the ITU-R BT.601 standard weighted sum:

gray = round(0.114*blue + 0.587*green + 0.299*red).

Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToGray.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]gray- an output 8-bit gray image.

◆ BgrToHsl()

void BgrToHsl ( const View< A > &  bgr,
View< A > &  hsl 
)

Converts a 24-bit BGR image to a 24-bit HSL (Hue, Saturation, Lightness) image.

The function converts a 24-bit BGR image to a 24-bit HSL image. For each output pixel: hsl[0] = hue, hsl[1] = saturation, hsl[2] = lightness. All HSL components are stored as 8-bit values in range [0, 255]. Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToHsl.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]hsl- an output 24-bit HSL image.

◆ BgrToHsv()

void BgrToHsv ( const View< A > &  bgr,
View< A > &  hsv 
)

Converts a 24-bit BGR image to a 24-bit HSV (Hue, Saturation, Value) image.

The function converts a 24-bit BGR image to a 24-bit HSV image. For each output pixel: hsv[0] = hue, hsv[1] = saturation, hsv[2] = value. All HSV components are stored as 8-bit values in range [0, 255]. Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToHsv.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]hsv- an output 24-bit HSV image.

◆ BgrToLab()

void BgrToLab ( const View< A > &  bgr,
View< A > &  lab 
)

Converts a 24-bit BGR image to a 24-bit CIELAB image.

The function converts a 24-bit BGR image to a 24-bit CIELAB image. For each output pixel: lab[0] = L, lab[1] = A, lab[2] = B. All LAB components are stored as 8-bit values (OpenCV-compatible CIELAB encoding). Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToLab.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]lab- an output 24-bit LAB image.

◆ BgrToRgb()

void BgrToRgb ( const View< A > &  bgr,
View< A > &  rgb 
)

Converts a 24-bit BGR image to a 24-bit RGB image by swapping the Red and Blue channels.

The function converts a 24-bit BGR (Blue, Green, Red) image to a 24-bit RGB (Red, Green, Blue) image. For each output pixel: rgb[0] = bgr[2], rgb[1] = bgr[1], rgb[2] = bgr[0]. Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToRgb.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]rgb- an output 24-bit RGB image.

◆ BgrToRgba()

void BgrToRgba ( const View< A > &  bgr,
View< A > &  rgba,
uint8_t  alpha = 0xFF 
)

Converts a 24-bit BGR image to a 32-bit RGBA image by swapping the Red and Blue channels and adding constant alpha.

The function converts a 24-bit BGR (Blue, Green, Red) image to a 32-bit RGBA (Red, Green, Blue, Alpha) image. For each pixel the Blue and Red channels are swapped, the Green channel is copied unchanged, and Alpha is set to the constant value specified by the alpha parameter. Both images must have the same width and height.

Note
This function is a C++ wrapper for function SimdRgbToBgra.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]rgba- an output 32-bit RGBA image.
[in]alpha- a constant value to fill the alpha channel of every output pixel. It is equal to 0xFF by default.

◆ BgrToYuv420p()

void BgrToYuv420p ( const View< A > &  bgr,
View< A > &  y,
View< A > &  u,
View< A > &  v,
SimdYuvType  yuvType = SimdYuvBt601 
)

Converts a 24-bit BGR image to planar YUV420P (4:2:0).

Y is computed for every source pixel from its B, G, R values. U and V are computed for every 2x2 block from averaged B, G, R values of this block. The input BGR and output Y images must have the same width and height. The output U and V images must have half width and half height relative to Y. The width and the height must be even.

Note
This function is a C++ wrapper for function SimdBgrToYuv420pV2.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]y- an output 8-bit image with Y color plane.
[out]u- an output 8-bit image with U color plane.
[out]v- an output 8-bit image with V color plane.
[in]yuvType- a type of output YUV image (see description of SimdYuvType). By default it is equal to SimdYuvBt601.

◆ BgrToYuv422p()

void BgrToYuv422p ( const View< A > &  bgr,
View< A > &  y,
View< A > &  u,
View< A > &  v,
SimdYuvType  yuvType = SimdYuvBt601 
)

Converts a 24-bit BGR image to planar YUV422P (4:2:2).

Y is computed for every source pixel from its B, G, R values. U and V are computed for each horizontal pair of pixels from averaged B, G, R values of this pair. The input BGR and output Y images must have the same width and height. The output U and V images must have half width and the same height relative to Y. The width must be even.

Note
This function is a C++ wrapper for function SimdBgrToYuv422pV2.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]y- an output 8-bit image with Y color plane.
[out]u- an output 8-bit image with U color plane.
[out]v- an output 8-bit image with V color plane.
[in]yuvType- a type of output YUV image (see description of SimdYuvType). By default it is equal to SimdYuvBt601.

◆ BgrToYuv444p()

void BgrToYuv444p ( const View< A > &  bgr,
View< A > &  y,
View< A > &  u,
View< A > &  v,
SimdYuvType  yuvType = SimdYuvBt601 
)

Converts a 24-bit BGR image to planar YUV444P (4:4:4).

Y, U and V are computed for every source pixel from its B, G, R values without chroma subsampling. The input BGR and output Y, U and V images must have the same width and height.

Note
This function is a C++ wrapper for function SimdBgrToYuv444pV2.
Parameters
[in]bgr- an input 24-bit BGR image.
[out]y- an output 8-bit image with Y color plane.
[out]u- an output 8-bit image with U color plane.
[out]v- an output 8-bit image with V color plane.
[in]yuvType- a type of output YUV image (see description of SimdYuvType). By default it is equal to SimdYuvBt601.