Combine pixel values of two images, overlay one image over another, or highlight selected pixels
Text & Graphics
visiontextngfix
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:
You can define the amount by which to scale each pixel value before combining them using the opacity factor, X, where , .
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.
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.
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.
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
.
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.
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
.
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.
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.
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.
These parameters apply only when the Operation parameter is set to
Blend
.
Select the rounding mode for fixed-point operations.
Select the overflow mode for fixed-point operations.
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 Toolbox™ software is 0.
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 Toolbox software is 0.
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 Toolbox software software is 0.
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 Toolbox software is 0.
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
(Fixed-Point Designer), a reference page on the
Fixed-Point Tool in the Simulink® documentation.
Port | Input/Output | Supported Data Types | Complex 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 |
| 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 |
| No |
Mask | Binary image that specifies which pixels to highlight | Same as Factor port When the Operation parameter is
set to | No |
Location | Two-element vector [x y], that specifies the position of the upper-left corner of the image input at port I2 |
| No |
Output | Vector or matrix of intensity or color values | Same as Image 1 port | No |
Computer Vision Toolbox | |
Computer Vision Toolbox | |
Computer Vision Toolbox |