Documentation

Compositing

Combine pixel values of two images, overlay one image over another, or highlight selected pixels

Library

Text & Graphics

visiontextngfix

Description

You can use the Compositing block to combine two images. Each pixel of the output image is a linear combination of the pixels in each input image. This process is defined by the following equation:

O(i,j)=(1X)*I1(i,j)+X*I2(i,j)

You can define the amount by which to scale each pixel value before combining them using the opacity factor, X, where , 0X1.

You can use the Compositing block to overlay one image over another image. The masking factor and the location determine which pixels are overwritten. Masking factors can be 0 or 1, where 0 corresponds to not overwriting pixels and 1 corresponds to overwriting pixels.

You can also use this block to highlight selected pixels in the input image. The block uses a binary input image at the Mask port, to specify which pixels to highlight.

    Note:   This block supports intensity and color images.

Fixed-Point Data Types

The following diagram shows the data types used in the Compositing block for fixed-point signals. These data types applies when the Operation parameter is set to Blend.

You can set the product output, accumulator, and output data types in the block mask as discussed in the next section.

Dialog Box

The Main pane of the Compositing dialog box appears as shown in the following figure.

Operation

Specify the operation you want the block to perform. If you choose Blend, the block linearly combines the pixels of one image with another image. If you choose Binary mask, the block overwrites the pixel values of one image with the pixel values of another image. If you choose Highlight selected pixels, the block uses the binary image input at the Mask port. Using this image, the block then determines which pixels are set to the maximum value supported by their data type.

 Blend

 Binary mask

 Highlight selected pixels

Opacity factor(s) source

Indicate where to specify any opacity factors. Your choices are Specify via dialog and Input port. This parameter is visible if, for the Operation parameter, you choose Blend.

Opacity factor(s)

Define the amount by which the block scales each pixel value before combining them. You can enter a scalar value used for all pixels or a matrix of values that defines the factor for each pixel. This parameter is visible if, for the Opacity factor(s) source parameter, you choose Specify via dialog. Tunable.

Mask source

Indicate where to specify any masking factors. Your choices are Specify via dialog and Input port. This parameter is visible if, for the Operation parameter, you choose Binary mask.

Mask

Define which pixels are overwritten. You can enter 0 or 1, which is used for all pixels, or a matrix of 0s and 1s that defines the factor for each pixel. This parameter is visible if, for the Mask source parameter, you choose Specify via dialog. Tunable.

Location source

Use this parameter to specify where to enter the location of the upper-left corner of the image input at input port Image2. You can choose either Specify via dialog or Input port.

When you choose Specify via dialog, you can set the Location [x y] parameter.

When you choose Input port, the Location port appears on the block. The input to this port must be a two-element vector as described for the Location [x y] parameter.

Location [x y]

Enter a two-element vector that specifies the row and column position of the upper-left corner of the image input at Image2 port. The position is relative to the upper-left corner of the image input at Image1 port. This parameter is visible if, for the Location source parameter, you choose Specify via dialog. Tunable.

Positive values move the image down and to the right; negative values move the image up and to the left. If the first element is greater than the number of rows in the Image1 matrix, the value is clipped to the total number of rows. If the second element is greater than the number of columns in the input Image1 matrix, the value is clipped to the total number of columns.

The Data Types pane of the Compositing dialog box appears as follows. These parameters apply only when the Operation parameter is set to Blend.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Opacity factor

Choose how to specify the word length and fraction length of the opacity factor:

  • When you select Same word length as input, these characteristics match those of the input to the block.

  • When you select Specify word length, enter the word length of the opacity factor.

  • When you select Binary point scaling, you can enter the word length of the opacity factor, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, of the opacity factor. The bias of all signals in the Computer Vision System Toolbox™ software is 0.

Product output

As the previous figure shows, the block places the output of the multiplier into the product output data type and scaling. Use this parameter to specify how to designate this product output word and fraction lengths.

  • When you select Same as first input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. The bias of all signals in the Computer Vision System Toolbox software is 0.

Accumulator

As the previous figure shows, the block takes inputs to the accumulator and casts them to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it.

  • When you select Same as product output, these characteristics match those of the product output.

  • When you select Same as first input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. The bias of all signals in the Computer Vision System Toolbox software software is 0.

Output

Choose how to specify the word length and fraction length of the output of the block:

  • When you select Same as first input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. The bias of all signals in the Computer Vision System Toolbox software is 0.

Lock data type settings against change by the fixed-point tools

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on the block mask. For more information, see fxptdlg, a reference page on the Fixed-Point Tool in the Simulink® documentation.

Supported Data Types

PortInput/OutputSupported Data TypesComplex Values Supported

Image 1

M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • Boolean

  • 8-, 16-, and 32-bit signed integer

  • 8-, 16-, and 32-bit unsigned integer

No

Image 2

M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes

Same as Image 1 port

No

Factor

Scalar or matrix of opacity or masking factor

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • Boolean

  • 8-, 16-, and 32-bit signed integer

  • 8-, 16-, and 32-bit unsigned integer

No

Mask

Binary image that specifies which pixels to highlight

Same as Factor port

When the Operation parameter is set to Highlight selected pixel, the input to the Mask port must be a Boolean data type.

No

Location

Two-element vector [x y], that specifies the position of the upper-left corner of the image input at port I2

  • Double-precision floating point. (Only supported if the input to the Image 1 and Image 2 ports is a floating-point data type.)

  • Single-precision floating point. (Only supported if the input to the Image 1 and Image 2 ports is a floating-point data type.)

  • 8-, 16-, and 32-bit signed integer

  • 8-, 16-, and 32-bit unsigned integer

No

Output

Vector or matrix of intensity or color values

Same as Image 1 port

No

See Also

Insert Text

Computer Vision System Toolbox

Draw Markers

Computer Vision System Toolbox

Draw Shapes

Computer Vision System Toolbox

Was this topic helpful?