Simd Library Documentation.

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

Functions for Gray-8 image conversions. More...

Functions

SIMD_API void SimdGrayToBgr (const uint8_t *gray, size_t width, size_t height, size_t grayStride, uint8_t *bgr, size_t bgrStride)
 Converts an 8-bit gray image to a 24-bit BGR image. More...
 
SIMD_API void SimdGrayToBgra (const uint8_t *gray, size_t width, size_t height, size_t grayStride, uint8_t *bgra, size_t bgraStride, uint8_t alpha)
 Converts an 8-bit gray image to a 32-bit BGRA image. More...
 
SIMD_API void SimdGrayToY (const uint8_t *gray, size_t grayStride, size_t width, size_t height, uint8_t *y, size_t yStride)
 Converts an 8-bit full-range gray image to an 8-bit limited-range Y plane. More...
 
template<template< class > class A>
SIMD_INLINE void GrayToBgr (const View< A > &gray, View< A > &bgr)
 Converts an 8-bit gray image to a 24-bit BGR image. More...
 
template<template< class > class A>
SIMD_INLINE void GrayToRgb (const View< A > &gray, View< A > &rgb)
 Converts an 8-bit gray image to a 24-bit RGB image. More...
 
template<template< class > class A>
SIMD_INLINE void GrayToBgra (const View< A > &gray, View< A > &bgra, uint8_t alpha=0xFF)
 Converts an 8-bit gray image to a 32-bit BGRA image. More...
 
template<template< class > class A>
SIMD_INLINE void GrayToRgba (const View< A > &gray, View< A > &rgba, uint8_t alpha=0xFF)
 Converts an 8-bit gray image to a 32-bit RGBA image. More...
 
template<template< class > class A>
SIMD_INLINE void GrayToY (const View< A > &gray, View< A > &y)
 Converts an 8-bit full-range gray image to an 8-bit limited-range Y plane. More...
 

Detailed Description

Functions for Gray-8 image conversions.

Function Documentation

◆ SimdGrayToBgr()

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

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

For every pixel:

bgr[3*x + 0] = gray[x];
bgr[3*x + 1] = gray[x];
bgr[3*x + 2] = gray[x];

Since all color channels receive the same value, the function can also be used for gray to RGB conversion.

All images must have the same width and height.

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

◆ SimdGrayToBgra()

void SimdGrayToBgra ( const uint8_t *  gray,
size_t  width,
size_t  height,
size_t  grayStride,
uint8_t *  bgra,
size_t  bgraStride,
uint8_t  alpha 
)

Converts an 8-bit gray image to a 32-bit BGRA image.

For every pixel:

bgra[4*x + 0] = gray[x];
bgra[4*x + 1] = gray[x];
bgra[4*x + 2] = gray[x];
bgra[4*x + 3] = alpha;

Since all color channels receive the same value, the function can also be used for gray to RGBA conversion.

All images must have the same width and height.

Note
This function has C++ wrappers: Simd::GrayToBgra(const View<A>& gray, View<A>& bgra, uint8_t alpha) and Simd::GrayToRgba(const View<A>& gray, View<A>& rgba, uint8_t alpha).
Parameters
[in]gray- a pointer to pixels data of input 8-bit gray image.
[in]width- an image width.
[in]height- an image height.
[in]grayStride- a row size of the gray image (in bytes).
[out]bgra- a pointer to pixels data of output 32-bit BGRA (or 32-bit RGBA) image.
[in]bgraStride- a row size of the bgra image (in bytes).
[in]alpha- a value of the alpha channel.

◆ SimdGrayToY()

void SimdGrayToY ( const uint8_t *  gray,
size_t  grayStride,
size_t  width,
size_t  height,
uint8_t *  y,
size_t  yStride 
)

Converts an 8-bit full-range gray image to an 8-bit limited-range Y plane.

For every pixel:

y[x] = RestrictRange(((220*gray[x] + 128) >> 8) + 16, 16, 235);

Thus gray value 0 maps to Y value 16, and gray value 255 maps to Y value 235.

All images must have the same width and height.

Note
This function has C++ wrappers: Simd::GrayToY(const View<A>& gray, View<A>& y).
Parameters
[in]gray- a pointer to pixels data of input 8-bit gray image.
[in]grayStride- a row size of the gray image (in bytes).
[in]width- an image width.
[in]height- an image height.
[out]y- a pointer to pixels data of output 8-bit Y plane.
[in]yStride- a row size of the y image (in bytes).

◆ GrayToBgr()

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

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

For every pixel:

bgr[x, y].blue = gray[x, y];
bgr[x, y].green = gray[x, y];
bgr[x, y].red = gray[x, y];

All images must have the same width and height.

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

◆ GrayToRgb()

void GrayToRgb ( const View< A > &  gray,
View< A > &  rgb 
)

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

For every pixel:

rgb[x, y].red = gray[x, y];
rgb[x, y].green = gray[x, y];
rgb[x, y].blue = gray[x, y];

All images must have the same width and height.

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

◆ GrayToBgra()

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

Converts an 8-bit gray image to a 32-bit BGRA image.

For every pixel:

bgra[x, y].blue = gray[x, y];
bgra[x, y].green = gray[x, y];
bgra[x, y].red = gray[x, y];
bgra[x, y].alpha = alpha;

All images must have the same width and height.

Note
This function is a C++ wrapper for function SimdGrayToBgra.
Parameters
[in]gray- an input 8-bit gray image.
[out]bgra- an output 32-bit BGRA image.
[in]alpha- a value of the alpha channel. It is equal to 0xFF by default.

◆ GrayToRgba()

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

Converts an 8-bit gray image to a 32-bit RGBA image.

For every pixel:

rgba[x, y].red = gray[x, y];
rgba[x, y].green = gray[x, y];
rgba[x, y].blue = gray[x, y];
rgba[x, y].alpha = alpha;

All images must have the same width and height.

Note
This function is a C++ wrapper for function SimdGrayToBgra.
Parameters
[in]gray- an input 8-bit gray image.
[out]rgba- an output 32-bit RGBA image.
[in]alpha- a value of the alpha channel. It is equal to 0xFF by default.

◆ GrayToY()

void GrayToY ( const View< A > &  gray,
View< A > &  y 
)

Converts an 8-bit full-range gray image to an 8-bit limited-range Y plane.

For every pixel:

y[x, y] = RestrictRange(((220*gray[x, y] + 128) >> 8) + 16, 16, 235);

Thus gray value 0 maps to Y value 16, and gray value 255 maps to Y value 235.

All images must have the same width and height.

Note
This function is a C++ wrapper for function SimdGrayToY.
Parameters
[in]gray- an input 8-bit gray image.
[out]y- an output 8-bit Y plane.