# 2.6.3.2 imgBlend(Pro)

Image: Arithmetic Transform: Alpha Blend

## Brief Information

Blend two images to form composite image

This feature is for OriginPro only.

## Command Line Usage

 

1. imgBlend img:=[Mbook1]1!mat(1) imgb:=[Mbook2]1!mat(1) opacity:=120; 

2. imgBlend img:=[Mbook1]1!mat(1) imgb:=[Mbook2]1!mat(1) x:=50 y:=10; 

## Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix img

Input

Image

<active>

Specifies the input image to be manipulated. The default input is the active image.

Image to Blend imgb

Input

Image

<unassigned>

Specifies an image used to blend the input image.

Opacity opacity

Input

int

128

Specifies the opacity of the Image to Blend. This value should be between 0 and 255.

Output Image oimg

Output

Image

<new>

Specifies the output image. By default, a new image will be created and used as output. See the syntax here.

Offset X x

Input

int

0

Specifies the vertical offset to change the relative position of the Image to Blend.

Offset Y y

Input

int

0

Specifies the horizontal offset to change the relative position of the Image to Blend.

Crop to Common Area crop

Input

int

1

Specifies whether to crop the output image to the common area of Input Image and Image to Blend.

## Description

A use of alpha blending is adding visual objects to a background image. This X-Function combines two images with a constant opacity: the first image is referred to as "Input Image" and the other one is referred to as "Image to Blend". The Image to Blend is made transparent and put on top of the Input Image, allowing user to see through the image on top to the image below. This tool allows you to set the opacity and the offset of the image to blend. In addition, it allows you decide whether to output the whole blended image or only the common area of the two images.

## Examples

In this example, we use the imgBlend function to combine two images (one in Mbook3 and the other in Mbook2):

1. When the input image is active, select Image: Arithmetic Transform: Alpha Blend. This opens the dialog of the X-Function.
2. In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.
 Input Image Image to Blend
Output Image

Note: OriginPro includes the ability to automatically recalculate the analysis result of the Alpha Blending operation any time you change the parameters or update your source data. In addition, the settings for the analysis routine can be saved to an analysis theme for use later with similar data.

## Algorithm

The computation uses L_AlphaBlendBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_AlphaBlendBitmap topic.

## References

LEADTOOLS Main API Help file, Version 14