RGB to RGBA Color Conversion
RGB to RGBA Color Conversion#
Converts an image from RGB to RGBA format.
Description
This function can operate with ROI (see Image Regions of Interest).
This function performs conversion from RGB image to RGBA image
leaving pixel values unchanged, only changing number of channels from 3 channels to 4 channels.
Alpha channel is filled with alpha_value
from spec
.
Headers
oneapi/ipl/convert.hpp
Syntax
-
template<typename SrcImageT, typename DstImageT>
sycl::event oneapi::ipl::rgb_to_rgba(sycl::queue &queue, SrcImageT &src, DstImageT &dst, const color_conversion_spec<typename DstImageT::data_t> &spec = {}, const std::vector<sycl::event> &dependencies = {})# Function for RGB to RGBA color conversion.
- Template Parameters
SrcImageT – Source image type
DstImageT – Destination image type
- Parameters
queue – SYCL queue object
src – Source image object
dst – Destination image object
spec – Specification for convert function
dependencies – SYCL event dependencies
- Returns
SYCL event
Parameters
See Parameters of Color Conversion (spec).
Errors
compile-time data type check |
Indicates an error when image data type is not supported. |
|
Indicates an error when ROI sizes of the source image and the destination image are not equal. |
|
Indicates an error when one of the pitch values is not divisible by size of component data type in bytes. |
The code example below demonstrates how shall be called
oneapi::ipl::rgb_to_rgba
for RGB to RGBA conversion:
using namespace oneapi;
sycl::queue queue;
ipl::shared_usm_allocator_t allocator{ queue };
const sycl::range<2> image_size{ height, width };
// Source image for RGB data
ipl::image<ipl::layouts::channel3, std::uint8_t> src_image{ queue, p_image_data, image_size, allocator };
// Destination image for RGBA data
ipl::image<ipl::layouts::channel4, std::uint8_t> dst_image{ image_size, allocator };
ipl::color_conversion_spec<std::uint8_t> spec{ 255 };
// Convert RGB to RGBA with alpha value = 255
auto event = ipl::rgb_to_rgba(queue, src_image, dst_image, spec);