Compositing

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

Library

Text & Graphics

Description

You can use the Compositing block to combine two images, where 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:

The opacity factor, X, where , defines the amount by which to scale each pixel value before combining them.

You can use the Compositing block to overlay a Image 2 over Image 1. The masking factor and the location determine which Image 1 pixels are overwritten. The masking factor(s) can be 0 or 1, where 0 corresponds to not overwriting pixels and 1 corresponds to overwriting pixels.

You can use the Compositing block to highlight selected pixels in the input image. Use a binary image, input at the Mask port, to specify which pixels to highlight.

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 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

Use the Operation parameter to 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 pixel, the block uses the binary image input at the Mask port to determine which pixels are set to the maximum value supported by their data type. For example, for every 1 in the binary image, the block sets the corresponding pixel in input image to the maximum value supported by its data type. For every 0 in the binary image, the block leaves the pixel value alone.

If, for the Operation parameter, you choose Blend, the Opacity factor(s) source parameter appears on the dialog box. Use this parameter to indicate where to specify the opacity factor(s).

If, for the Operation parameter, you choose Binary mask, the Mask source parameter appears on the dialog box. Use this parameter to indicate where to specify the masking factor(s).

Use the Location source parameter to specify where to enter the zero-based location of the upper-left corner of the image input at port I2.

If, for the Operation parameter, you choose Highlight selected pixels, the Location source parameter appears on the dialog box. This parameter is described above.

Fixed-Point Data Types

The following diagram shows the data types used in the Compositing block for fixed-point signals. It is only applicable 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 pixel, the block uses the binary image input at the Mask port to determine which pixels are set to the maximum value supported by their data type.

Opacity factor(s) source

Indicate where to specify the opacity factor(s). 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 the masking factor(s). 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 port I2. Your choices are Specify via dialog and Input port.

Location [row column]

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

The Fixed-point pane of the Compositing dialog box appears as follows. These parameters are applicable 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:

Product output

As depicted in the previous figure, the output of the multiplier is placed into the product output data type and scaling. Use this parameter to specify how to designate this product output word and fraction lengths.

Accumulator

As depicted in the previous figure, inputs to the accumulator are cast 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. Use this parameter to specify how to designate this accumulator word and fraction lengths.

Output

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

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool. For more information, see fxptdlg, a reference page on the Fixed-Point Tool in the Simulink® documentation.

See Also

Insert Text

Video and Image Processing Blockset

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS