ImageDev

BlendAlphaChannelWithImage

Blends an RGBA input image with a background RGB image into an RGB output image.

Access to parameter description

For an introduction to color image filters: section Color Transforms.

BlendAlphaChannelWithImage combines an image with a background, defined by an RGB image, taking into account the alpha channel.
Considering all $\alpha$ values between 0 and 1, the resulting intensity of each color component is computed with the following formula:
$O=I_i*\alpha + I_b*\left (1-\alpha \right )$ where Thus, for the alpha channel, a value of 0 means that the pixel is fully transparent; the resulting color will be the color of the background image. A value of 1 means that the pixel is fully opaque; the resulting color will be the color of the input image.

See also

Function Syntax

This function returns the outputRgbImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
blendAlphaChannelWithImage( std::shared_ptr< iolink::ImageView > inputRgbaImage,
                            std::shared_ptr< iolink::ImageView > inputBackgroundImage,
                            std::shared_ptr< iolink::ImageView > outputRgbImage = NULL );
This function returns the outputRgbImage output parameter.
// Function prototype.
blend_alpha_channel_with_image( input_rgba_image, input_background_image, output_rgb_image = None )
This function returns the outputRgbImage output parameter.
// Function prototype.
public static IOLink.ImageView
BlendAlphaChannelWithImage( IOLink.ImageView inputRgbaImage,
                            IOLink.ImageView inputBackgroundImage,
                            IOLink.ImageView outputRgbImage = null );

Class Syntax

Parameters

Class Name BlendAlphaChannelWithImage

Parameter Name Description Type Supported Values Default Value
input
inputRgbaImage
The RGBA input image. Image Multispectral nullptr
input
inputBackgroundImage
The background input image. Its spatial dimensions and type must be the same as the RGBA input image. If the image has an alpha channel, it is ignored. Its dimensions and type must be the same as the RGBA input image. Image Multispectral nullptr
output
outputRgbImage
The RGB output image. Its spatial dimensions and type are forced to the same values as the inputs. Image nullptr

Object Examples

std::shared_ptr< iolink::ImageView > icon = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "icon.png" );
std::shared_ptr< iolink::ImageView > icon_rainbow = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "icon_rainbow.png" );

BlendAlphaChannelWithImage blendAlphaChannelWithImageAlgo;
blendAlphaChannelWithImageAlgo.setInputRgbaImage( icon );
blendAlphaChannelWithImageAlgo.setInputBackgroundImage( icon_rainbow );
blendAlphaChannelWithImageAlgo.execute();

std::cout << "outputRgbImage:" << blendAlphaChannelWithImageAlgo.outputRgbImage()->toString();
icon = ioformat.read_image(imagedev_data.get_image_path("icon.png"))
icon_rainbow = ioformat.read_image(imagedev_data.get_image_path("icon_rainbow.png"))

blend_alpha_channel_with_image_algo = imagedev.BlendAlphaChannelWithImage()
blend_alpha_channel_with_image_algo.input_rgba_image = icon
blend_alpha_channel_with_image_algo.input_background_image = icon_rainbow
blend_alpha_channel_with_image_algo.execute()

print( "output_rgb_image:", str( blend_alpha_channel_with_image_algo.output_rgb_image ) );
ImageView icon = ViewIO.ReadImage( @"Data/images/icon.png" );
ImageView icon_rainbow = ViewIO.ReadImage( @"Data/images/icon_rainbow.png" );

BlendAlphaChannelWithImage blendAlphaChannelWithImageAlgo = new BlendAlphaChannelWithImage
{
    inputRgbaImage = icon,
    inputBackgroundImage = icon_rainbow
};
blendAlphaChannelWithImageAlgo.Execute();

Console.WriteLine( "outputRgbImage:" + blendAlphaChannelWithImageAlgo.outputRgbImage.ToString() );

Function Examples

std::shared_ptr< iolink::ImageView > icon = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "icon.png" );
std::shared_ptr< iolink::ImageView > icon_rainbow = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "icon_rainbow.png" );

auto result = blendAlphaChannelWithImage( icon, icon_rainbow );

std::cout << "outputRgbImage:" << result->toString();
icon = ioformat.read_image(imagedev_data.get_image_path("icon.png"))
icon_rainbow = ioformat.read_image(imagedev_data.get_image_path("icon_rainbow.png"))

result = imagedev.blend_alpha_channel_with_image( icon, icon_rainbow )

print( "output_rgb_image:", str( result ) );
ImageView icon = ViewIO.ReadImage( @"Data/images/icon.png" );
ImageView icon_rainbow = ViewIO.ReadImage( @"Data/images/icon_rainbow.png" );

IOLink.ImageView result = Processing.BlendAlphaChannelWithImage( icon, icon_rainbow );

Console.WriteLine( "outputRgbImage:" + result.ToString() );