Main Content

vision.AlphaBlender

(Not recommended) Combine images, overlay images, or highlight selected pixels

The vision.AlphaBlender system object is not recommended. Use the imblend function to blend two images, instead.

Description

The AlphaBlender System object™ combines two images, overlays one image over another, or highlights selected pixels.

To combine two images, overlay one image over another, or highlight selected pixels:

  1. Create the vision.AlphaBlender object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

alphablend = vision.AlphaBlender creates an alpha blender System object, alphablend, which combines two images, overlays one image over another, or highlights selected pixels.

example

alphablend = vision.AlphaBlender(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, alphablend = vision.AlphaBlender('Operation','Blend')

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Operation, specified as 'Blend', 'Binary mask', or 'Highlight selected pixels'.

OperationDescription
'Blend'Linearly combine the pixels of one image with the another image.
'Binary mask'Overwrite the pixel values of one image with the pixel values of another image.
'Highlight selected pixels'Uses the mask binary image input to determine which pixels are set to the maximum value supported by their data type.

Source of opacity factor, specified as 'Property' or 'Input port'. This property applies when you set the Operation property to Blend.

Pixel scale value, specified as a scalar or matrix. The object scales each pixel before combining the images. This property applies when you set the OpacitySource property to Property.

Tunable: Yes

Binary mask source, specified as 'Property' or 'Input port'. This property applies when you set the Operation property to Binary mask

Overwrite scalar, specified as 0 or 1 for every pixel, or a matrix of 0s and 1s. This property applies when you set the MaskSource property to Property.

Tunable: Yes

Source of location of the upper-left corner of second input image

Source for the upper-left corner location of the second input image, specified as Property or Input port.

Location of the upper-left corner of the second input image relative to the location of the first input image, specified as a two-element vector in the format [x y]. This property applies when you set the LocationSource property to Property.

See Coordinate Systems for a discussion on pixel coordinates and spatial coordinates, which are the two main coordinate systems used in the Computer Vision Toolbox™.

Tunable: Yes

Fixed-Point Properties

Rounding method, specified as 'Ceiling','Convergent', 'Floor', 'Nearest', 'Round', 'Simplest', or 'Zero'.

Overflow action for fixed-point operations, specified as 'Wrap' or 'Saturate'.

Opacity word and fraction lengths for fixed-point operations, specified as 'Same word length as input' or 'Custom'.

Opacity word and fraction lengths factor for fixed-point operations, specified as an unscaled numerictype (Fixed-Point Designer) object with a Signedness of Auto. This property applies when you set the OpacityDataType property to Custom

Product word and fraction lengths, specified as 'Custom' or 'Same as first input'.

Product word and fraction lengths, specified as a scaled numerictype (Fixed-Point Designer) object with a 'Signedness' of 'Auto'. This property applies when you set the 'ProductDataType' property to 'Custom'

Accumulator word and fraction lengths, specified as 'Same as product', 'Same as first input', or 'Custom'.

Accumulator word and fraction lengths, specified as a scaled numerictype (Fixed-Point Designer) object with a 'Signedness' of 'Auto'.

Output word and fraction lengths, specified as 'Same as first input' or 'Custom'.

Output word and fraction lengths, specified as a scaled numerictype (Fixed-Point Designer) object with a 'Signedness' of 'Auto'.

Usage

Description

ab = alphablend(I1,I2) returns an alpha blender object that blends images I1 and I2.

ab = alphablend(I1,I2,opacity) uses the opacity input to combine pixel values of I1 and I2. To use the opacity input, you must set the Operation property to 'Blend' and the OpacitySource property to 'Input port'

ab = alphablend(I1,I2,mask) uses the mask input to overlay I1 over I2. To use the mask input with an overlay, you must set the Operation property to 'Binary mask' and the MaskSource property to 'Input port'.

ab = alphablend(I1,mask) uses the mask input to determine which pixels in I1 are set to the maximum value supported by their data type. To use the mask input with an overlay, you must set the Operation property to 'Highlight selected pixels' and the MaskSource property to 'Input port'.

ab = alphablend(I1,I2,___,location) additionally sets the upper-left corner location for I2. To use the location input, you must set the LocationSource property to 'Input port'.

Input Arguments

expand all

Input image, specified in truecolor or 2-D grayscale.

Data Types: single | double | int16 | uint8 | uint16

Input image, specified in truecolor or 2-D grayscale.

Data Types: single | double | int16 | uint8 | uint16

Pixel scale value, specified as a scalar or matrix. The object scales each pixel before combining the images.

Overwrite scalar, specified as 0 or 1 for every pixel, or a matrix of 0s and 1s.

Location of the upper-left corner of the second input image relative to the location of the first input image, specified as a two-element vector in the format [x y].

Tunable: Yes

Output Arguments

expand all

Output blended image, returned as a combined image, overlayed image, or an image with selected pixels highlighted.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Display the two images.

I1 = im2single(imread("blobs.png"));
I2 = im2single(imread("circles.png"));
subplot(1,2,1);
imshow(I1);
subplot(1,2,2);
imshow(I2);

Figure contains 2 axes objects. Hidden axes object 1 contains an object of type image. Hidden axes object 2 contains an object of type image.

Blend the two images and display the result.

J = imblend(I2,I1);
figure;
imshow(J);

Figure contains an axes object. The hidden axes object contains an object of type image.

Extended Capabilities

Version History

Introduced in R2012a

collapse all

R2024b: vision.AlphaBlender system object is not recommended

The vision.AlphaBlender system object is not recommended and will be removed in a future release. Use the imblend function to blend two images, instead.

See Also