Functions for RGBA-32 image conversions. More...
Functions | |
| SIMD_API void | SimdRgbaToGray (const uint8_t *rgba, size_t width, size_t height, size_t rgbaStride, uint8_t *gray, size_t grayStride) |
| Converts a 32-bit RGBA image to an 8-bit gray image. More... | |
| template<template< class > class A> | |
| SIMD_INLINE void | RgbaToBgr (const View< A > &rgba, View< A > &bgr) |
| Converts a 32-bit RGBA image to a 24-bit BGR image by swapping Red/Blue and dropping alpha. More... | |
| template<template< class > class A> | |
| SIMD_INLINE void | RgbaToBgra (const View< A > &rgba, View< A > &bgra) |
| Converts a 32-bit RGBA image to a 32-bit BGRA image by swapping the Red and Blue channels. More... | |
| template<template< class > class A> | |
| SIMD_INLINE void | RgbaToGray (const View< A > &rgba, View< A > &gray) |
| Converts a 32-bit RGBA image to an 8-bit grayscale image. More... | |
| template<template< class > class A> | |
| SIMD_INLINE void | RgbaToRgb (const View< A > &rgba, View< A > &rgb) |
| Converts a 32-bit RGBA image to a 24-bit RGB image by dropping the alpha channel. More... | |
Detailed Description
Functions for RGBA-32 image conversions.
Function Documentation
◆ SimdRgbaToGray()
| void SimdRgbaToGray | ( | const uint8_t * | rgba, |
| size_t | width, | ||
| size_t | height, | ||
| size_t | rgbaStride, | ||
| uint8_t * | gray, | ||
| size_t | grayStride | ||
| ) |
Converts a 32-bit RGBA image to an 8-bit gray image.
All images must have the same width and height. For every pixel:
gray[i] = (0.299*R + 0.587*G + 0.114*B) rounded to nearest integer, where R = rgba[4*i + 0], G = rgba[4*i + 1], B = rgba[4*i + 2]. The alpha channel is ignored.
- Note
- This function has a C++ wrapper Simd::RgbaToGray(const View<A>& rgba, View<A>& gray).
- Parameters
-
[in] rgba - a pointer to pixels data of input 32-bit RGBA image. [in] width - an image width. [in] height - an image height. [in] rgbaStride - a row size of the rgba image in bytes. [out] gray - a pointer to pixels data of output 8-bit gray image. [in] grayStride - a row size of the gray image in bytes.
◆ RgbaToBgr()
Converts a 32-bit RGBA image to a 24-bit BGR image by swapping Red/Blue and dropping alpha.
The function converts a 32-bit RGBA (Red, Green, Blue, Alpha) image to a 24-bit BGR (Blue, Green, Red) image. The Red and Blue channels are swapped, the Green channel is copied unchanged, and the alpha channel is discarded. Both images must have the same width and height.
- Note
- This function is a C++ wrapper for function SimdBgraToRgb.
- Parameters
-
[in] rgba - an input 32-bit RGBA image. [out] bgr - an output 24-bit BGR image.
◆ RgbaToBgra()
Converts a 32-bit RGBA image to a 32-bit BGRA image by swapping the Red and Blue channels.
The function converts a 32-bit RGBA (Red, Green, Blue, Alpha) image to a 32-bit BGRA (Blue, Green, Red, Alpha) image. The Red and Blue channels are swapped, while the Green and Alpha channels are copied unchanged for each pixel. Both images must have the same width and height.
- Note
- This function is a C++ wrapper for function SimdBgraToRgba.
- Parameters
-
[in] rgba - an input 32-bit RGBA image. [out] bgra - an output 32-bit BGRA image.
◆ RgbaToGray()
Converts a 32-bit RGBA image to an 8-bit grayscale image.
The alpha channel is ignored. The luminance value of each pixel is calculated from the Red, Green, and Blue channels using the ITU-R BT.601 standard weighted sum:
gray = round(0.299*red + 0.587*green + 0.114*blue), where red = rgba[0], green = rgba[1], blue = rgba[2].
Both images must have the same width and height.
- Note
- This function is a C++ wrapper for function SimdRgbaToGray.
- Parameters
-
[in] rgba - an input 32-bit RGBA image. [out] gray - an output 8-bit gray image.
◆ RgbaToRgb()
Converts a 32-bit RGBA image to a 24-bit RGB image by dropping the alpha channel.
The function converts a 32-bit RGBA (Red, Green, Blue, Alpha) image to a 24-bit RGB (Red, Green, Blue) image. The Red, Green, and Blue channels are copied unchanged for each pixel; the alpha channel is discarded. Both images must have the same width and height.
- Note
- This function is a C++ wrapper for function SimdBgraToBgr.
- Parameters
-
[in] rgba - an input 32-bit RGBA image. [out] rgb - an output 24-bit RGB image.