This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

vision.AlphaBlender

Combine images, overlay images, or highlight selected pixels

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? (MATLAB).

Creation

Syntax

alphablend = vision.AlphaBlender
alphablend = vision.AlphaBlender(Name,Value)

Description

example

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

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 (MATLAB).

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', 'Zero', or 'Floor'

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 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 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 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 object with a 'Signedness' of 'Auto'.

Usage

For versions earlier than R2016b, use the step function to run the System object algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Syntax

ab = alphablend(I1,I2)
ab = alphablend(I1,I2,opacity)
ab = alphablend(I1,I2,mask)
ab = alphablend(I1,mask)
ab = alphablend(I1,I2,___,location)

Description

ab = alphablend(I1,I2) returns a 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

expand 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);

Blend the two images and display the result.

halphablend = vision.AlphaBlender;
J = step(halphablend,I1,I2);
figure;
imshow(J);

Extended Capabilities

See Also

Introduced in R2012a