Computer Vision System Toolbox™ Reference PDF
Computer Vision System Toolbox™ Reference PDF
Reference
R2014a
How to Contact MathWorks
www.mathworks.com Web
comp.soft-sys.matlab Newsgroup
www.mathworks.com/contact_TS.html Technical Support
508-647-7000 (Phone)
508-647-7001 (Fax)
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
April 2011 Online only Revised for Version 4.0 (Release 2011a)
September 2011 Online only Revised for Version 4.1 (Release 2011b)
March 2012 Online only Revised for Version 5.0 (Release 2012a)
September 2012 Online only Revised for Version 5.1 (Release R2012b)
March 2013 Online only Revised for Version 5.2 (Release R2013a)
September 2013 Online only Revised for Version 5.3 (Release R2013b)
March 2014 Online only Revised for Version 6.0 (Release R2014a)
Contents
Alphabetical List
2
Functions Alphabetical
3
v
vi Contents
1
Library Statistics
visionstatistics
( Ma −1) ( Na −1)
C(i, j) = ∑ ∑ A(m, n) ⋅ conj( A(m + i, n + j))
m =0 n =0
Complex
Port Input/Output Supported Data Types Values
Supported
Input Vector or matrix of • Double-precision floating point Yes
intensity values or a
• Single-precision floating point
scalar, vector, or matrix
that represents one plane • Fixed point
of the RGB video stream
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Output Autocorrelation of the Same as Input port Yes
input matrix
If the data type of the input is floating point, the output of the block has
the same data type.
1-2
2-D Autocorrelation
You can set the product output, accumulator, and output data types in
the block mask as discussed in “Dialog Box” on page 1-4.
The output of the multiplier is in the product output data type if at
least one of the inputs to the multiplier is real. If both of the inputs
to the multiplier are complex, the result of the multiplication is in
the accumulator data type. For details on the complex multiplication
performed, refer to “Multiplication Data Types”.
1-3
2-D Autocorrelation
Dialog The Main pane of the 2-D Autocorrelation dialog box appears as shown
Box in the following figure.
The Data Types pane of the 2-D Autocorrelation dialog box appears
as shown in the following figure.
1-4
2-D Autocorrelation
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
1-5
2-D Autocorrelation
Product output
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-3 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type
in this block:
• When you select Same as 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
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 1-3 and “Multiplication Data Types” for illustrations
depicting the use of the accumulator data type in this block.
The accumulator data type is only used when both inputs to the
multiplier are complex.
• When you select Same as product output, these
characteristics match those of the product output.
• When you select Same as 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
is 0.
1-6
2-D Autocorrelation
Output
Choose how to specify the output word length and fraction length.
• When you select Same as 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.
1-7
2-D Convolution
Library Filtering
visionfilter
Description
( Ma −1) ( Na −1)
C(i, j) = ∑ ∑ A(m, n) * B(i − m, j − n)
m =0 n =0
Complex
Port Input/Output Supported Data Types Values
Supported
I1 Matrix of intensity • Double-precision floating point Yes
values or a matrix that
• Single-precision floating point
represents one plane of
the RGB video stream • Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
I2 Matrix of intensity Same as I1 port Yes
values or a matrix that
1-8
2-D Convolution
Complex
Port Input/Output Supported Data Types Values
Supported
If the data type of the input is floating point, the output of the block has
the same data type.
The dimensions of the output are dictated by the Output size
parameter. Assume that the input at port I1 has dimensions (Ma, Na)
and the input at port I2 has dimensions (Mb, Nb). If, for the Output
size parameter, you choose Full, the output is the full two-dimensional
convolution with dimensions (Ma+Mb-1, Na+Nb-1). If, for the Output
size parameter, you choose Same as input port I1, the output is the
central part of the convolution with the same dimensions as the input at
port I1. If, for the Output size parameter, you choose Valid, the output
is only those parts of the convolution that are computed without the
zero-padded edges of any input. This output has dimensions (Ma-Mb+1,
Na-Nb+1). However, if all(size(I1)<size(I2)), the block errors out.
If you select the Output normalized convolution
check box, the block’s output is divided by
sqrt(sum(dot(I1p,I1p))*sum(dot(I2,I2))), where I1p is the
portion of the I1 matrix that aligns with the I2 matrix. See “Example 2”
on page 1-12 for more information.
1-9
2-D Convolution
You can set the product output, accumulator, and output data types in
the block mask as discussed in “Dialog Box” on page 1-15.
The output of the multiplier is in the product output data type if at
least one of the inputs to the multiplier is real. If both of the inputs
to the multiplier are complex, the result of the multiplication is in
the accumulator data type. For details on the complex multiplication
performed, refer to “Multiplication Data Types”.
Examples Example 1
Suppose I1, the first input matrix, has dimensions (4,3) and I2, the
second input matrix, has dimensions (2,2). If, for the Output size
parameter, you choose Full, the block uses the following equations to
determine the number of rows and columns of the output matrix:
1-10
2-D Convolution
If, for the Output size parameter, you choose Same as input port
I1, the output is the central part of Cfull with the same dimensions as
the input at port I1, (4,3). However, since a 4-by-3 matrix cannot be
extracted from the exact center of Cfull , the block leaves more rows and
columns on the top and left side of the Cfull matrix and outputs:
If, for the Output size parameter, you choose Valid, the block uses the
following equations to determine the number of rows and columns of
the output matrix:
1-11
2-D Convolution
Example 2
In convolution, the value of an output element is computed as a
weighted sum of neighboring elements.
For example, suppose the first input matrix represents an image and
is defined as
I1 = [17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9]
I2 = [8 1 6
3 5 7
4 9 2]
The following figure shows how to compute the (1,1) output element
(zero-based indexing) using these steps:
1-12
2-D Convolution
1 Rotate the second input matrix, I2, 180 degrees about its center
element.
2 Slide the center element of I2 so that it lies on top of the (0,0) element
of I1.
1-13
2-D Convolution
2 9 4
7 5 3
Alignment of center
element of I2
6 1 8
17 24 1 8 15
4 6 13 20 22
Alignment of I2 matrix
10 12 19 21 3
11 18 25 2 9
1-14
2-D Convolution
Dialog The Main pane of the 2-D Convolution dialog box appears as shown in
Box the following figure.
1-15
2-D Convolution
Output size
This parameter controls the size of the output scalar, vector, or
matrix produced as a result of the convolution between the two
inputs. If you choose Full, the output has dimensions (Ma+Mb-1,
Na+Nb-1). If you choose Same as input port I1, the output has
the same dimensions as the input at port I1. If you choose Valid,
output has dimensions (Ma-Mb+1, Na-Nb+1).
Output normalized convolution
If you select this check box, the block’s output is normalized.
The Data Types pane of the 2-D Convolution dialog box appears as
shown in the following figure.
1-16
2-D Convolution
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
1-17
2-D Convolution
Product output
Use this parameter to specify how to designate the product output
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 1-9 and “Multiplication Data Types” for illustrations
depicting the use of the product output data type in this block:
• When you select Same as first input, these characteristics
match those of the first 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 theComputer Vision System Toolbox
software is 0.
Accumulator
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 1-9 and “Multiplication Data Types” for illustrations
depicting the use of the accumulator data type in this block.
The accumulator data type is only used when both inputs to the
multiplier are complex:
1-18
2-D Convolution
1-19
2-D Correlation
Library Statistics
visionstatistics
1-20
2-D Correlation
Description
1-21
( Ma −1) ( Na −1)
C(i, j) = ∑ ∑ A(m, n) ⋅ conj( B(m + i, n + j))
m =0 n =0
Complex
Port Input/Output Supported Data Types Values
Supported
I1 Vector or matrix of • Double-precision floating point Yes
intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
I2 Scalar, vector, or matrix Same as I1 port Yes
of intensity values or a
scalar, vector, or matrix
that represents one plane
of the RGB video stream
Output Convolution of the input Same as I1 port Yes
matrices
If the data type of the input is floating point, the output of the block is
the same data type.
The dimensions of the output are dictated by the Output size
parameter and the sizes of the inputs at ports I1 and I2. For example,
assume that the input at port I1 has dimensions (Ma, Na) and the input
at port I2 has dimensions (Mb, Nb). If, for the Output size parameter,
you choose Full, the output is the full two-dimensional cross-correlation
with dimensions (Ma+Mb-1, Na+Nb-1). If, for the Output size
parameter, you choose Same as input port I1, the output is the
central part of the cross-correlation with the same dimensions as the
input at port I1. If, for the Output size parameter, you choose Valid,
1-22
2-D Correlation
the output is only those parts of the cross-correlation that are computed
without the zero-padded edges of any input. This output has dimensions
(Ma-Mb+1, Na-Nb+1). However, if all(size(I1)<size(I2)), the block
errors out.
If you select the Normalized output check box, the block’s output
is divided by sqrt(sum(dot(I1p,I1p))*sum(dot(I2,I2))), where
I1p is the portion of the I1 matrix that aligns with the I2 matrix. See
“Example 2” on page 1-26 for more information.
Note When you select the Normalized output check box, the block
input cannot be fixed point.
You can set the product output, accumulator, and output data types in
the block mask as discussed in “Dialog Box” on page 1-29.
The output of the multiplier is in the product output data type if at
least one of the inputs to the multiplier is real. If both of the inputs
to the multiplier are complex, the result of the multiplication is in
the accumulator data type. For details on the complex multiplication
performed, refer to “Multiplication Data Types”.
1-23
2-D Correlation
Examples Example 1
Suppose I1, the first input matrix, has dimensions (4,3). I2, the second
input matrix, has dimensions (2,2). If, for the Output size parameter,
you choose Full, the block uses the following equations to determine
the number of rows and columns of the output matrix:
If, for the Output size parameter, you choose Same as input port
I1, the output is the central part of Cfull with the same dimensions as
the input at port I1, (4,3). However, since a 4-by-3 matrix cannot be
extracted from the exact center of Cfull , the block leaves more rows and
columns on the top and left side of the Cfull matrix and outputs:
1-24
2-D Correlation
If, for the Output size parameter, you choose Valid, the block uses the
following equations to determine the number of rows and columns of
the output matrix:
1-25
2-D Correlation
Example 2
In cross-correlation, the value of an output element is computed as a
weighted sum of neighboring elements.
For example, suppose the first input matrix represents an image and
is defined as
I1 = [17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9]
I2 = [8 1 6
3 5 7
4 9 2]
The following figure shows how to compute the (2,4) output element
(zero-based indexing) using these steps:
1 Slide the center element of I2 so that lies on top of the (1,3) element
of I1.
1-26
2-D Correlation
Values of I2 matrix
8 1 6
3 5 7
Alignment of I2 matrix
4 9 2
17 24 1 8 15
4 6 13 20 22
Alignment of center
10 12 19 21 3 element of I2
11 18 25 2 9
1-27
2-D Correlation
1-28
2-D Correlation
Dialog The Main pane of the 2-D Correlation dialog box appears as shown in
Box the following figure.
1-29
2-D Correlation
Output size
This parameter controls the size of the output scalar, vector, or
matrix produced as a result of the cross-correlation between
the two inputs. If you choose Full, the output has dimensions
(Ma+Mb-1, Na+Nb-1). If you choose Same as input port I1, the
output has the same dimensions as the input at port I1. If you
choose Valid, output has dimensions (Ma-Mb+1, Na-Nb+1).
Normalized output
If you select this check box, the block’s output is normalized.
The Data Types pane of the 2-D Correlation dialog box appears as
shown in the following figure.
1-30
2-D Correlation
1-31
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
2-D Correlation
Overflow mode
Select the Overflow mode for fixed-point operations.
Product output
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-23 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type
in this block:
• When you select Same as first input, these characteristics
match those of the first 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
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 1-23 and“Multiplication Data Types” for illustrations
1-32
2-D Correlation
1-33
2-D Correlation
1-34
2-D DCT
Library Transforms
visiontransforms
Description The 2-D DCT block calculates the two-dimensional discrete cosine
transform of the input signal. The equation for the two-dimensional
DCT is
M −1 N −1
2 (2 x + 1)mπ (2 y + 1)nπ
F (m, n) =
MN
C(m)C(n) ∑ ∑ f ( x, y) cos
2M
cos
2N
x =0 y =0
Complex
Port Input/Output Supported Data Types Values
Supported
Input Vector or matrix of • Double-precision floating point No
intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
If the data type of the input signal is floating point, the output of the
block is the same data type.
1-35
2-D DCT
Use the Sine and cosine computation parameter to specify how the
block computes the sine and cosine terms in the DCT algorithm. If
you select Trigonometric fcn, the block computes the sine and cosine
values during the simulation. If you select Table lookup, the block
computes and stores the trigonometric values before the simulation
starts. In this case, the block requires extra memory.
1-36
2-D DCT
1-37
2-D DCT
The output of the multiplier is in the product output data type when
at least one of the inputs to the multiplier is real. When both inputs
to the multiplier are complex, the result of the multiplication is in
the accumulator data type. For details on the complex multiplication
performed, refer to “Multiplication Data Types”. You can set the sine
table, product output, accumulator, and output data types in the block
mask as discussed in the next section.
Dialog The Main pane of the 2-D DCT dialog box appears as shown in the
Box following figure.
1-38
2-D DCT
The Data Types pane of the 2-D DCT dialog box appears as shown in
the following figure.
Rounding mode
Select the “Rounding Modes” for fixed-point operations. The sine
table values do not obey this parameter; they always round to
Nearest.
Overflow mode
Select the Overflow mode for fixed-point operations. The sine
table values do not obey this parameter; instead, they are always
saturated.
1-39
2-D DCT
The sine table values do not obey the Rounding mode and
Overflow mode parameters; instead, they are always saturated
and rounded to Nearest.
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-36 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type in
this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator data type
Specify the accumulator data type. See “Fixed-Point Data Types”
on page 1-36 for illustrations depicting the use of the accumulator
data type in this block. You can set this parameter to:
1-40
2-D DCT
See “Specify Data Types Using Data Type Assistant” for more
information.
Output data type
Specify the output data type. See “Fixed-Point Data Types” on
page 1-36 for illustrations depicting the use of the output data
type in this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule.
When you select Inherit: Inherit via internal rule, the
block calculates the output word length and fraction length
automatically. The internal rule first calculates an ideal output
word length and fraction length using the following equations:
Using these ideal results, the internal rule then selects word
lengths and fraction lengths that are appropriate for your
hardware. For more information, see “Inherit via Internal
Rule”.
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
1-41
2-D DCT
See “Specify Data Types Using Data Type Assistant” for more
information.
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.
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.
References [1] Chen, W.H, C.H. Smith, and S.C. Fralick, “A fast computational
algorithm for the discrete cosine transform,” IEEE Trans. Commun.,
vol. COM-25, pp. 1004-1009. 1977.
[2] Wang, Z. “Fast algorithms for the discrete W transform and for
the discrete Fourier transform,” IEEE Trans. Acoust., Speech, Signal
Processing, vol. ASSP-32, pp. 803-816, Aug. 1984.
1-42
2-D FFT
Library Transforms
visiontransforms
Description The 2-D FFT block computes the fast Fourier transform (FFT). The
block does the computation of a two-dimensional M-by-N input matrix
in two steps. First it computes the one-dimensional FFT along one
dimension (row or column). Then it computes the FFT of the output of
the first step along the other dimension (column or row).
The output of the 2-D FFT block is equivalent to the MATLAB® fft2
function:
M −1 N −1 2πmx 2πny
−j −j
F (m, n) = ∑ ∑ f ( x, y) e M e N
x =0 y =0
where 0 ≤ m ≤ M − 1 and 0 ≤ n ≤ N − 1 .
1-43
2-D FFT
The output of this block has the same dimensions as the input. If
the input signal has a floating-point data type, the data type of the
output signal uses the same floating-point data type. Otherwise, the
output can be any fixed-point data type. The block computes scaled
and unscaled versions of the FFT.
The input to this block can be floating-point or fixed-point, real or
complex, and conjugate symmetric. The block uses one of two possible
FFT implementations. You can select an implementation based on the
FFTW library [1], [2], or an implementation based on a collection of
Radix-2 algorithms. You can select Auto to allow the block to choose
the implementation.
Port Description
Complex
Port Description Supported Data Types Values
Supported
Input Vector or matrix of • Double-precision Yes
intensity values floating point
• Single-precision
floating point
• Fixed point
• 8-, 16-, 32-bit signed
integer
• 8-, 16-, 32-bit unsigned
integer
FFTW Implementation
The FFTW implementation provides an optimized FFT calculation
including support for power-of-two and non-power-of-two transform
1-44
2-D FFT
Radix-2 Implementation
The Radix-2 implementation supports bit-reversed processing, fixed or
floating-point data, and allows the block to provide portable C-code
generation using the “Simulink Coder™”. The dimensions of the input
matrix, M and N, must be powers of two. To work with other input
sizes, use the Image Pad block to pad or truncate these dimensions to
powers of two, or if possible choose the FFTW implementation.
With Radix-2 selected, the block implements one or more of the
following algorithms:
• Butterfly operation
• Double-signal algorithm
• Half-length algorithm
• Radix-2 decimation-in-time (DIT) algorithm
• Radix-2 decimation-in-frequency (DIF) algorithm
Radix-2 DIF
1-45
2-D FFT
Radix-2 DIF
2πk
j
e K
1-46
2-D FFT
1-47
2-D FFT
1-48
2-D FFT
Dialog The Main pane of the 2-D FFT dialog box appears as shown in the
Box following figure.
1-49
2-D FFT
FFT implementation
Set this parameter to FFTW [1], [2] to support an arbitrary length
input signal. The block restricts generated code with FFTW
implementation to host computers capable of running MATLAB.
Set this parameter to Auto to let the block choose the FFT
implementation. For non-power-of-two transform lengths, the
block restricts generated code to MATLAB host computers.
Output in bit-reversed order
Designate the order of the output channel elements relative to
the ordering of the input elements. When you select this check
box, the output channel elements appear in bit-reversed order
relative to the input ordering. If you clear this check box, the
output channel elements appear in linear order relative to the
input ordering.
The Data Types pane of the 2-D FFT dialog box appears as shown in
the following figure.
1-50
2-D FFT
1-51
2-D FFT
Rounding mode
Select the “Rounding Modes” for fixed-point operations. The sine
table values do not obey this parameter; instead, they always
round to Nearest.
Overflow mode
Select the Overflow mode for fixed-point operations. The sine
table values do not obey this parameter; instead, they are always
saturated.
Sine table data type
Choose how you specify the word length of the values of the sine
table. The fraction length of the sine table values always equals
the word length minus one. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit: Same
word length as input
• An expression that evaluates to a valid data type, for example,
fixdt(1,16)
The sine table values do not obey the Rounding mode and
Overflow mode parameters; instead, they are always saturated
and rounded to Nearest.
Product output data type
Specify the product output data type. See Fixed-Point Data Types
on page 47 and “Multiplication Data Types” for illustrations
depicting the use of the product output data type in this block.
You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
1-52
2-D FFT
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator data type
Specify the accumulator data type. See Fixed-Point Data Types
on page 47 for illustrations depicting the use of the accumulator
data type in this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Output data type
Specify the output data type. See Fixed-Point Data Types on page
47 for illustrations depicting the use of the output data type in
this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule.
When you select Inherit: Inherit via internal rule, the
block calculates the output word length and fraction length
automatically. The internal rule first calculates an ideal output
word length and fraction length using the following equations:
— When you select the Divide butterfly outputs by two
check box, the ideal output word and fraction lengths are the
same as the input word and fraction lengths.
1-53
2-D FFT
Using these ideal results, the internal rule then selects word
lengths and fraction lengths that are appropriate for your
hardware. For more information, see “Inherit via Internal
Rule”.
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
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.
1-54
2-D FFT
2 Find the mirror image of each binary entry, and write it beside the
original binary representation.
If, on the 2-D FFT block parameters dialog box, you select the Output
in bit-reversed order check box, the block bit-reverses the order of
both the columns and the rows. The next diagram illustrates the linear
and bit-reversed outputs of the 2-D FFT block. The output values are
the same, but they appear in different order.
1-55
2-D FFT
0 1 2 3 4 5 6 7
Bit-reversed row
and column indices
1-56
2-D FFT
1-57
2-D FFT (To Be Removed)
Library Transforms
Description
Note The 2-D FFT block is obsolete. It may be removed in a future
version of the Computer Vision System Toolbox software. Use the
replacement block 2-D FFT.
1-58
2-D FIR Filter
Library Filtering
visionfilter
Description The 2-D Finite Impulse Response (FIR) filter block filters the input
matrix I using the coefficient matrix H or the coefficient vectors HH
and HV.
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of • Double-precision floating point Yes
intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
H Matrix of filter coefficients Same as I port. Yes
HH Vector of filter coefficients Same as I port. The input to ports Yes
HH and HV must be the same
data type.
HV Vector of filter coefficients Same as I port. The input to ports Yes
HH and HV must be the same
data type.
PVal Scalar value that Input must have the same data Yes
represents the constant type as the input to I port.
pad value
Output Scalar, vector, or matrix Same as I port. Yes
of filtered values
1-59
2-D FIR Filter
If the input has a floating-point data type, then the output uses the
same data type. Otherwise, the output can be any fixed-point data type.
Select the Separable filter coefficients check box if your filter
coefficients are separable. Using separable filter coefficients reduces
the amount of calculations the block must perform to compute the
output. For example, suppose your input image is M-by-N and your
filter coefficient matrix is x-by-y. For a nonseparable filter with the
Output size parameter set to Same as input port I, it would take
x⋅ y⋅ M ⋅ N
multiply-accumulate (MAC) operations for the block to calculate the
output. For a separable filter, it would only take
( x + y) ⋅ M ⋅ N
MAC operations. If you do not know whether or not your filter
coefficients are separable, use the isfilterseparable function.
Here is an example of the function syntax, [S, HCOL, HROW] =
isfilterseparable(H). The isfilterseparable function takes the
filter kernel, H, and returns S, HCOL and HROW. Here, S is a Boolean
variable that is 1 if the filter is separable and 0 if it is not. HCOL is a
vector of vertical filter coefficients, and HROW is a vector of horizontal
filter coefficients.
Use the Coefficient source parameter to specify how to define your
filter coefficients. If you select the Separable filter coefficients check
box and then select a Coefficient source of Specify via dialog, the
Vertical coefficients (across height) and Horizontal coefficients
(across width) parameters appear in the dialog box. You can use these
parameters to enter vectors of vertical and horizontal filter coefficients,
respectively.
You can also use the variables HCOL and HROW, the output of the
isfilterseparable function, for these parameters. If you select the
Separable filter coefficients check box and then select a Coefficient
source of Input port, ports HV and HH appear on the block. Use
these ports to specify vectors of vertical and horizontal filter coefficients.
1-60
2-D FIR Filter
If you clear the Separable filter coefficients check box and select
a Coefficient source of Specify via dialog, the Coefficients
parameter appears in the dialog box. Use this parameter to enter your
matrix of filter coefficients.
If you clear the Separable filter coefficients check box and select a
Coefficient source of Input port, port H appears on the block. Use
this port to specify your filter coefficient matrix.
The block outputs the result of the filtering operation at the Output
port. The Output size parameter and the sizes of the inputs at ports I
and H dictate the dimensions of the output. For example, assume that
the input at port I has dimensions (Mi, Ni) and the input at port H has
dimensions (Mh, Nh). If you select anOutput size of Full, the output
has dimensions (Mi+Mh-1, Ni+Nh-1). If you select an Output size of
Same as input port I, the output has the same dimensions as the
input at port I. If you select an Output size of Valid, the block filters
the input image only where the coefficient matrix fits entirely within
it, so no padding is required. The output has dimensions (Mi-Mh+1,
Ni-Nh+1). However, if all(size(I)<size(H)), the block errors out.
Use the Padding options parameter to specify how to pad the
boundary of your input matrix. To pad your matrix with a constant
value, select Constant. To pad your input matrix by repeating its border
values, select Replicate. To pad your input matrix with its mirror
image, select Symmetric. To pad your input matrix using a circular
repetition of its elements, select Circular. For more information on
padding, see the Image Pad block reference page.
If, for the Padding options parameter, you select Constant, the
Pad value source parameter appears in the dialog box. If you select
Specify via dialog, the Pad value parameter appears in the dialog
box. Use this parameter to enter the constant value with which to pad
your matrix. If you select Pad value source ofInput port, the PVal
port appears on the block. Use this port to specify the constant value
with which to pad your matrix. The pad value must be real if the input
image is real. You will get an error message if the pad value is complex
when the input image is real.
1-61
2-D FIR Filter
( Ma −1) ( Na −1)
C(i, j) = ∑ ∑ A(m, n) * H (i − m, j − n)
m =0 n =0
( Ma −1) ( Na −1)
C(i, j) = ∑ ∑ A(m, n) ⋅ conj( H (m + i, n + j))
m =0 n =0
1-62
2-D FIR Filter
You can set the coefficient, product output, accumulator, and output
data types in the block mask as discussed in “Dialog Box” on page 1-63.
The output of the multiplier is in the product output data type if at
least one of the inputs to the multiplier is real. If both of the inputs
to the multiplier are complex, the result of the multiplication is in
the accumulator data type. For details on the complex multiplication
performed, refer to “Multiplication Data Types”.
Dialog The Main pane of the 2-D FIR Filter dialog box appears as shown in
Box the following figure.
1-63
2-D FIR Filter
1-64
2-D FIR Filter
values. Select Symmetricto pad your input matrix with its mirror
image. Select Circular to pad your input matrix using a circular
repetition of its elements. This parameter appears if you select an
Output size of Full or Same as input port I.
Pad value source
Use this parameter to specify how to define your constant
boundary value. Select Specify via dialog to enter your value
in the block parameters dialog box. Select Input port to specify
your constant value using the PVal port. This parameter appears
if you select a Padding options of Constant.
Pad value
Enter the constant value with which to pad your matrix. This
parameter is visible if, for the Pad value source parameter, you
select Specify via dialog. Tunable. The pad value must be real
if the input image is real. You will get an error message if the pad
value is complex when the input image is real.
Filtering based on
Specify the algorithm by which the block filters the input matrix.
You can select Convolution or Correlation.
The Data Types pane of the 2-D FIR Filter dialog box appears as
shown in the following figure.
1-65
2-D FIR Filter
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
Coefficients
Choose how to specify the word length and the fraction length
of the filter coefficients.
• When you select Inherit: Same word length as input,
the word length of the filter coefficients match that of the
input to the block. In this mode, the block automatically sets
1-66
2-D FIR Filter
The filter coefficients do not obey the Rounding mode and the
Overflow mode parameters; instead, they always saturated and
rounded to Nearest.
See “Specify Data Types Using Data Type Assistant” for more
information.
Product output
Use this parameter to specify how to designate the product output
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 1-62 and “Multiplication Data Types” for illustrations
depicting the use of the product output data type in this block:
• When you select Inherit: Same as input, these
characteristics match those of the input to the block.
• When you select fixdt([],16,0), you can enter the word
length and the fraction length of the product output, in bits.
1-67
2-D FIR Filter
• When you select <data type expression>, you can enter the
data type expression.
If you set the Coefficent source (on the Main tab) to Input port
the Product Output will inherit its sign according to the inputs.
If either or both input I1 and I2 are signed, the Product Output
will be signed. Otherwise, the Product Output is unsigned. The
following table shows all cases.
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types” on
page 1-62 and “Multiplication Data Types” in the DSP System
Toolbox™ documentation for illustrations depicting the use of the
accumulator data type in this block. The accumulator data type is
only used when both inputs to the multiplier are complex:
• When you select Inherit: Same as input, these
characteristics match those of the input to the block.
• When you select Inherit: Same as product output, these
characteristics match those of the product output.
1-68
2-D FIR Filter
See “Specify Data Types Using Data Type Assistant” for more
information.
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select Inherit: Same as input, these
characteristics match those of the input to the block.
• When you select fixdt([],16,0), you can enter the word
length and the fraction length of the output, in bits.
You can choose to set signedness of the output to Auto, Signed
or Unsigned.
• When you select <data type expression>, you can enter the
a data type expression.
See “Specify Data Types Using Data Type Assistant” for more
information.
1-69
2-D FIR Filter
1-70
2-D Histogram
Library Statistics
visionstatistics
Description The 2-D Histogram block computes the frequency distribution of the
elements in the input. You must use the Find the histogram over
parameter to specify whether the block computes the histogram for
Each column of the input or of the Entire input. The Running
histogram check box allows you to select between basic operation and
running operation, as described below.
The block distributes the elements of the input into the number of
discrete bins specified by the Number of bins parameter, n.
The 2-D Histogram block sorts all complex input values into bins
according to their magnitude.
The histogram value for a given bin represents the frequency of
occurrence of the input values bracketed by that bin. You specify
the upper boundary of the highest-valued bin in the Upper limit of
histogram parameter, BM, and the lower boundary of the lowest-valued
bin in the Lower limit of histogram parameter, Bm. The bins have
equal width of
BM Bm
n
1
Bm k k 0, 1, 2,..., n 1
2
Input values that fall on the border between two bins are placed into
the lower valued bin; that is, each bin includes its upper boundary.
For example, a bin of width 4 centered on the value 5 contains the
1-71
2-D Histogram
input value 7, but not the input value 3. Input values greater than
the Upper limit of histogram parameter or less than Lower limit
of histogram parameter are placed into the highest valued or lowest
valued bin, respectively.
The values you enter for the Upper limit of histogram and Lower
limit of histogram parameters must be real-valued scalars. NaN and
inf are not valid values for the Upper limit of histogram and Lower
limit of histogram parameters.
Basic Operation
When the Running histogram check box is not selected, the 2-D
Histogram block computes the frequency distribution of the current
input.
When you set the Find the histogram over parameter to Each
column, the 2-D Histogram block computes a histogram for each column
of the M-by-N matrix independently. The block outputs an n-by-N
matrix, where n is the Number of bins you specify. The jth column of
the output matrix contains the histogram for the data in the jth column
of the M-by-N input matrix.
When you set the Find the histogram over parameter to Entire
input, the 2-D Histogram block computes the frequency distribution
for the entire input vector, matrix or N-D array. The block outputs an
n-by-1 vector, where n is the Number of bins you specify.
Running Operation
When you select the Running histogram check box, the 2–D
Histogram block computes the frequency distribution of both the past
and present data for successive inputs. The block resets the histogram
(by emptying all of the bins) when it detects a reset event at the optional
Rst port. See “Resetting the Running Histogram” on page 1-73 for more
information on how to trigger a reset.
When you set the Find the histogram over parameter to Each
column, the 2-D Histogram block computes a running histogram for
each column of the M-by-N matrix. The block outputs an n-by-N matrix,
where n is the Number of bins you specify. The jth column of the
1-72
2-D Histogram
output matrix contains the running histogram for the jth column of
the M-by-N input matrix.
When you set the Find the histogram over parameter to Entire
input, the 2-D Histogram block computes a running histogram for the
data in the first dimension of the input. The block outputs an n-by-1
vector, where n is the Number of bins you specify.
Note When the 2-D Histogram block is used in running mode and
the input data type is non-floating point, the output of the histogram
is stored as a uint32 data type. The largest number that can be
represented by this data type is 232-1. If the range of the uint32 data
type is exceeded, the output data will wrap back to 0.
• Rising edge — Triggers a reset operation when the Rst input does
one of the following:
- Rises from a negative value to a positive value or zero
- Rises from zero to a positive value, where the rise is not a
continuation of a rise from a negative value to zero (see the
following figure)
1-73
2-D Histogram
• Falling edge — Triggers a reset operation when the Rst input does
one of the following:
- Falls from a positive value to a negative value or zero
- Falls from zero to a negative value, where the fall is not a
continuation of a fall from a positive value to zero (see the following
figure)
1-74
2-D Histogram
Dialog The Main pane of the 2-D Histogram block dialog appears as follows.
Box
1-75
2-D Histogram
1-76
2-D Histogram
Normalized
When selected, the output vector, v, is normalized such that
sum(v) = 1.
The Data Types pane of the 2-D Histogram block dialog appears as
follows.
1-77
2-D Histogram
Note The fixed-point parameters listed are only used for fixed-point
complex inputs, which are distributed by squared magnitude.
1-78
2-D Histogram
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
Product output data type
Specify the product output data type. See “Multiplication Data
Types” for illustrations depicting the use of the product output
data type. You can set it to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator data type
Specify the accumulator data type. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
1-79
2-D Histogram
1-80
2-D Histogram (To Be Removed)
Library Statistics
Description
Note The 2-D Histogram block is obsolete. It may be removed in a
future version of the Computer Vision System Toolbox software. Use
the replacement block Histogram.
1-81
2-D IDCT
Library Transforms
visiontransforms
M −1 N −1
2 (2 x + 1)mπ (2 y + 1)nπ
f ( x, y) =
MN
∑ ∑ C(m)C(n) F (m, n) cos 2M
cos
2N
m =0 n =0
C(m), C(n) = 1
where F(m,n) is the DCT of the signal f(x,y) and 2 for
m, n = 0 and C(m), C(n) = 1 otherwise.
The number of rows and columns of the input signal must be powers
of two. The output of this block has dimensions the same dimensions
as the input.
Complex
Port Input/Output Supported Data Types Values
Supported
Input Vector or matrix of • Double-precision floating No
intensity values point
• Single-precision floating
point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned
integer
1-82
2-D IDCT
If the data type of the input signal is floating point, the output of the
block is the same data type.
Use the Sine and cosine computation parameter to specify how the
block computes the sine and cosine terms in the IDCT algorithm. If
you select Trigonometric fcn, the block computes the sine and cosine
values during the simulation. If you select Table lookup, the block
computes and stores the trigonometric values before the simulation
starts. In this case, the block requires extra memory.
1-83
2-D IDCT
1-84
2-D IDCT
The output of the multiplier is in the product output data type when
at least one of the inputs to the multiplier is real. When both of the
inputs to the multiplier are complex, the result of the multiplication is
in the accumulator data type. For details on the complex multiplication
performed, refer to “Multiplication Data Types”. You can set the sine
table, product output, accumulator, and output data types in the block
mask as discussed in the next section.
Dialog The Main pane of the 2-D IDCT dialog box appears as shown in the
Box following figure.
1-85
2-D IDCT
you select Table lookup, the block computes and stores the
trigonometric values before the simulation starts. In this case, the
block requires extra memory.
The Data Types pane of the 2-D IDCT dialog box appears as shown in
the following figure.
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations. The sine
table values do not obey this parameter; instead, they are always
saturated.
1-86
2-D IDCT
The sine table values do not obey the Rounding mode and
Overflow mode parameters; instead, they are always saturated
and rounded to Nearest.
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-83 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type in
this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator data type
Specify the accumulator data type. See “Fixed-Point Data Types”
on page 1-83 for illustrations depicting the use of the accumulator
data type in this block. You can set this parameter to:
1-87
2-D IDCT
See “Specify Data Types Using Data Type Assistant” for more
information.
Output data type
Specify the output data type. See “Fixed-Point Data Types” on
page 1-83 for illustrations depicting the use of the output data
type in this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule.
When you select Inherit: Inherit via internal rule, the
block calculates the output word length and fraction length
automatically. The internal rule first calculates an ideal output
word length and fraction length using the following equations:
Using these ideal results, the internal rule then selects word
lengths and fraction lengths that are appropriate for your
hardware. For more information, see “Inherit via Internal
Rule”.
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
1-88
2-D IDCT
See “Specify Data Types Using Data Type Assistant” for more
information.
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.
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.
References [1] Chen, W.H, C.H. Smith, and S.C. Fralick, “A fast computational
algorithm for the discrete cosine transform,”IEEE Trans. Commun.,
vol. COM-25, pp. 1004-1009. 1977.
[2] Wang, Z. “Fast algorithms for the discrete W transform and for
the discrete Fourier transform,” IEEE Trans. Acoust., Speech, Signal
Processing, vol. ASSP-32, pp. 803-816, Aug. 1984.
1-89
2-D IFFT
Library Transforms
visiontransforms
Description The 2-D IFFT block computes the inverse fast Fourier transform
(IFFT) of an M-by-N input matrix in two steps. First, it computes the
one-dimensional IFFT along one dimension (row or column). Next,
it computes the IFFT of the output of the first step along the other
dimension (column or row).
The output of the IFFT block is equivalent to the MATLAB ifft2
function:
M −1 N −1 2πmx 2πny
1 j j
f ( x, y) =
MN
∑ ∑ F (m, n)e M e N
m =0 n =0
where 0 ≤ x ≤ M − 1 and 0 ≤ y ≤ N − 1 .
The output of this block has the same dimensions as the input. If
the input signal has a floating-point data type, the data type of the
output signal uses the same floating-point data type. Otherwise, the
output can be any fixed-point data type. The block computes scaled
and unscaled versions of the IFFT.
The input to this block can be floating-point or fixed-point, real or
complex, and conjugate symmetric. The block uses one of two possible
FFT implementations. You can select an implementation based on the
FFTW library [1], [2], or an implementation based on a collection of
Radix-2 algorithms. You can select Auto to allow the block to choose
the implementation.
1-90
2-D IFFT
Port Description
Complex
Port Description Supported Data Types Values
Supported
Input Vector or matrix of • Double-precision Yes
intensity values floating point
• Single-precision
floating point
• Fixed point
• 8-, 16-, 32-bit signed
integer
• 8-, 16-, 32-bit unsigned
integer
FFTW Implementation
The FFTW implementation provides an optimized FFT calculation
including support for power-of-two and non-power-of-two transform
lengths in both simulation and code generation. Generated code
using the FFTW implementation will be restricted to MATLAB host
computers. The data type must be floating-point. Refer to “Simulink
Coder” for more details on generating code.
Radix-2 Implementation
The Radix-2 implementation supports bit-reversed processing, fixed or
floating-point data, and allows the block to provide portable C-code
generation using the “Simulink Coder”. The dimensions of the input
matrix, M and N, must be powers of two. To work with other input
sizes, use the Image Pad block to pad or truncate these dimensions to
powers of two, or if possible choose the FFTW implementation.
1-91
2-D IFFT
• Butterfly operation
• Double-signal algorithm
• Half-length algorithm
• Radix-2 decimation-in-time (DIT) algorithm
• Radix-2 decimation-in-frequency (DIF) algorithm
Radix-2 DIF
1-92
2-D IFFT
Radix-2 DIF
2πk
j
e K
1-93
2-D IFFT
output, and output data types displayed in the diagrams in the IFFT
dialog box as discussed in “Dialog Box” on page 1-96.
Inputs to the IFFT block are first cast to the output data type and stored
in the output buffer. Each butterfly stage then processes signals in the
accumulator data type, with the final output of the butterfly being cast
back into the output data type. The block multiplies in a twiddle factor
before each butterfly stage in a decimation-in-time IFFT and after each
butterfly stage in a decimation-in-frequency IFFT.
1-94
2-D IFFT
1-95
2-D IFFT
Dialog The Main pane of the 2-D IFFT dialog box appears as shown in the
Box following figure.
1-96
2-D IFFT
1-97
2-D IFFT
FFT implementation
Set this parameter to FFTW [1], [2] to support an arbitrary length
input signal. The block restricts generated code with FFTW
implementation to MATLAB host computers.
Set this parameter to Auto to let the block choose the FFT
implementation. For non-power-of-two transform lengths, the
block restricts generated code to MATLAB host computers.
Input is in bit-reversed order
Select or clear this check box to designate the order of the input
channel elements. Select this check box when the input should
appear in reversed order, and clear it when the input should
appear in linear order. The block yields invalid outputs when you
do not set this parameter correctly. This check box only appears
when you set the FFT implementation parameter to Radix-2
or Auto.
The FFT block yields conjugate symmetric output when you input
real-valued data. Taking the IFFT of a conjugate symmetric input
1-98
2-D IFFT
If the IFFT block inputs conjugate symmetric data and you do not
select this check box, the IFFT block outputs a complex-valued
signal with small imaginary parts. The block outputs invalid data
if you select this option with non conjugate symmetric input data.
Divide output by product of FFT length in each input dimension
Select this check box to compute the scaled IFFT. The block
computes scaled and unscaled versions of the IFFT. If you select
this option, the block computes the scaled version of the IFFT.
The unscaled IFFT is defined by the following equation:
M −1 N −1 2πmx 2πny
j j
f ( x, y) = ∑ ∑ F (m, n)e M e N
m =0 n =0
where 0 ≤ x ≤ M − 1 and 0 ≤ y ≤ N − 1 .
1
version by .
MN
The Data Types pane of the 2-D IFFT dialog box appears as shown in
the following figure.
1-99
2-D IFFT
1-100
2-D IFFT
Rounding mode
Select the “Rounding Modes” for fixed-point operations. The sine
table values do not obey this parameter; instead, they always
round to Nearest.
Overflow mode
Select the Overflow mode for fixed-point operations. The sine
table values do not obey this parameter; instead, they are always
saturated.
Sine table data type
Choose how you specify the word length of the values of the sine
table. The fraction length of the sine table values always equals
the word length minus one. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit: Same
word length as input
• An expression that evaluates to a valid data type, for example,
fixdt(1,16)
The sine table values do not obey the Rounding mode and
Overflow mode parameters; instead, they are always saturated
and rounded to Nearest.
Product output data type
Specify the product output data type. See Fixed-Point Data Types
on page 93 and “Multiplication Data Types” for illustrations
depicting the use of the product output data type in this block.
You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
1-101
2-D IFFT
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator data type
Specify the accumulator data type. SeeFixed-Point Data Types on
page 93 for illustrations depicting the use of the accumulator data
type in this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Output data type
Specify the output data type. See Fixed-Point Data Types on page
93 for illustrations depicting the use of the output data type in
this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit:
Inherit via internal rule.
When you select Inherit: Inherit via internal rule, the
block calculates the output word length and fraction length
automatically. The internal rule first calculates an ideal output
word length and fraction length using the following equations:
— When you select the Divide butterfly outputs by two
check box, the ideal output word and fraction lengths are the
same as the input word and fraction lengths.
1-102
2-D IFFT
Using these ideal results, the internal rule then selects word
lengths and fraction lengths that are appropriate for your
hardware. For more information, see “Inherit via Internal
Rule”.
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
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.
1-103
2-D IFFT
1-104
2-D IFFT (To Be Removed)
Library Transforms
viptransforms
Description
Note The 2-D IFFT block is obsolete. It may be removed in a future
version of the Computer Vision System Toolbox software. Use the
replacement block 2-D IFFT.
1-105
2-D Maximum
Library Statistics
visionstatistics
Description The 2-D Maximum block identifies the value and/or position of the
smallest element in each row or column of the input, or along a specified
dimension of the input. The 2-D Maximum block can also track the
maximum values in a sequence of inputs over a period of time.
The 2-D Maximum block supports real and complex floating-point,
fixed-point, and Boolean inputs. Real fixed-point inputs can be either
signed or unsigned, while complex fixed-point inputs must be signed.
The output data type of the maximum values match the data type of
the input. The block outputs double index values, when the input is
double, and uint32 otherwise.
Port Descriptions
1-106
2-D Maximum
• Single-precision
floating point
• Boolean
• 8-, 16-, and 32-bit
signed integers
• 8-, 16-, and 32-bit
unsigned integers
1-107
2-D Maximum
Value Mode
When you set the Mode parameter to Value, the block computes the
maximum value in each row or column of the input, along vectors of a
specified dimension of the input, or of the entire input at each sample
time, and outputs the array y. Each element in y is the maximum
value in the corresponding column, row, vector, or entire input. The
output y depends on the setting of the Find the maximum value
over parameter. For example, consider a 3-dimensional input signal
of size M-by-N-by-P:
For complex inputs, the block selects the value in each row or column
of the input, along vectors of a specified dimension of the input, or of
1-108
2-D Maximum
the entire input that has the maximum magnitude squared as shown
2 2
below. For complex value u a bi , the magnitude squared is a b .
Index Mode
When you set the Mode parameter to Index, the block computes the
maximum value in each row or column of the input, along vectors of a
specified dimension of the input, or of the entire input, and outputs the
index array I. Each element in I is an integer indexing the maximum
value in the corresponding column, row, vector, or entire input. The
output I depends on the setting of the Find the maximum value
over parameter. For example, consider a 3-dimensional input signal
of size M-by-N-by-P:
1-109
2-D Maximum
When a maximum value occurs more than once, the computed index
corresponds to the first occurrence. For example, when the input is
the column vector [3 2 1 2 3]', the computed one-based index of the
maximum value is 1 rather than 5 when Each column is selected.
When inputs to the block are double-precision values, the index values
are double-precision values. Otherwise, the index values are 32-bit
unsigned integer values.
Running Mode
When you set the Mode parameter to Running, the block tracks the
maximum value of each channel in a time sequence of M-by-N inputs.
In this mode, the block treats each element as a channel.
1-110
2-D Maximum
• Rising edge — Triggers a reset operation when the Rst input does
one of the following:
- Rises from a negative value to a positive value or zero
- Rises from zero to a positive value, where the rise is not a
continuation of a rise from a negative value to zero (see the
following figure)
Rising edge
Rising edge
• Falling edge — Triggers a reset operation when the Rst input does
one of the following:
- Falls from a positive value to a negative value or zero
- Falls from zero to a negative value, where the fall is not a
continuation of a fall from a positive value to zero (see the following
figure)
1-111
2-D Maximum
ROI Processing
To calculate the statistical value within a particular region of interest
(ROI) of the input, select the Enable ROI processing check box. This
applies to any mode other than running mode and when you set the
Find the maximum value over parameter to Entire input and you
select the Enable ROI processing check box. ROI processing applies
only for 2-D inputs.
You can specify a rectangle, line, label matrix, or binary mask ROI type.
Use the binary mask to specify which pixels to highlight or select.
Use the label matrix to label regions. Pixels set to 0 represent the
background. Pixels set to 1 represent the first object, pixels set to 2,
1-112
2-D Maximum
represent the second object, and so on. Use the Label Numbers port
to specify the objects in the label matrix for which the block calculates
statistics. The input to this port must be a vector of scalar values that
correspond to the labeled regions in the label matrix.
For rectangular ROIs, use the ROI portion to process parameter to
specify whether to calculate the statistical value for the entire ROI or
just the ROI perimeter. For more information about the format of the
input to the ROI port when you set the ROI to a rectangle or a line, see
the Draw Shapes block reference page.
ROI Output Statistics
Output = Individual statistics for each ROI
Flag Description
Port
Output
0 ROI is completely outside the input image.
1 ROI is completely or partially inside the input image.
Flag Description
Port
Output
0 All ROIs are completely outside the input image.
1 At least one ROI is completely or partially inside the
input image.
If the ROI is partially outside the image, the block only computes the
statistical values for the portion of the ROI that is within the image.
1-113
2-D Maximum
Flag Description
Port
Output
0 Label number is not in the label matrix.
1 Label number is in the label matrix.
Flag Description
Port
Output
0 None of the label numbers are in the label matrix.
1 At least one of the label numbers is in the label matrix.
1-114
2-D Maximum
Dialog The Main pane of the Maximum block dialog appears as follows.
Box
Mode
Specify the block’s mode of operation:
• Value and Index — Output both the value and the index
location.
1-115
2-D Maximum
For the Value, Index, and Value and Index modes, the 2-D
Maximum block produces identical results as the MATLAB max
function when it is called as [y I] = max(u,[],D), where u and
y are the input and output, respectively, D is the dimension, and
I is the index.
Find the maximum value over
Specify whether the block should find the maximum of the entire
input each row, each column, or dimensions specified by the
Dimension parameter.
Reset port
Specify the reset event that causes the block to reset the running
maximum. The rate of the reset signal must be a positive integer
multiple of the rate of the data signal input. This parameter
appears only when you set the Mode parameter to Running. For
information about the possible values of this parameter, see
“Resetting the Running Maximum” on page 1-110.
Dimension
Specify the dimension (one-based value) of the input signal, over
which the maximum is computed. The value of this parameter
cannot exceed the number of dimensions in the input signal. This
parameter applies only when you set the Find the maximum
value over parameter to Specified dimension.
Enable ROI processing
Select this check box to calculate the statistical value within a
particular region of each image. This parameter applies only
1-116
2-D Maximum
when you set the Find the maximum value over parameter to
Entire input, and the block is not in running mode.
ROI type
Specify the type of ROI you want to use. Your choices are
Rectangles, Lines, Label matrix, or Binary mask.
When you set this parameter to Label matrix, the Label and
Label Numbers ports appear on the block and the Output
flag indicating if input label numbers are valid check box
appears in the dialog box. If you select this check box, the Flag
port appears on the block.
1-117
2-D Maximum
The Data Types pane of the Maximum block dialog appears as follows.
1-118
2-D Maximum
Note The parameters on the Data Types pane are only used for
complex fixed-point inputs. The sum of the squares of the real and
imaginary parts of such an input are formed before a comparison is
made, as described in “Value Mode” on page 1-108. The results of the
squares of the real and imaginary parts are placed into the product
output data type. The result of the sum of the squares is placed into
the accumulator data type. These parameters are ignored for other
types of inputs.
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-114 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type
in this block. You can set it to:
• A rule that inherits a data type, for example, Inherit: Same
as input
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
1-119
2-D Maximum
See “Specify Data Types Using Data Type Assistant” for more
information.
Lock data type settings against changes 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.
Examples
The ex_vision_2dmaximum example finds the maximum value within
two ROIs. The model outputs the maximum values and their one-based
[x y] coordinate locations.
1-120
2-D Maximum
1-121
2-D Maximum (To Be Removed)
Library vipobslib
Description
Note This 2-D Maximum block will be removed in a future release. It
uses the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated 2-D Maximum block that
uses the one-based, [x y] coordinate system.
1-122
2-D Mean
Library Statistics
visionstatistics
Description The 2-D Mean block computes the mean of each row or column of the
input, along vectors of a specified dimension of the input, or of the entire
input. The 2-D Mean block can also track the mean value in a sequence
of inputs over a period of time. To track the mean value in a sequence of
inputs, select the Running mean check box.
Port Description
1-123
2-D Mean
Binary Mask:
• Boolean
Label • 8-, 16-, and 32-bit unsigned integers
Label • 8-, 16-, and 32-bit unsigned integers
Numbers
Output • Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed integers
• 8-, 16-, and 32-bit unsigned integers
Flag • Boolean
Basic Operation
When you do not select the Running mean check box, the block
computes the mean value in each row or column of the input, along
vectors of a specified dimension of the input, or of the entire input at
each individual sample time. Each element in the output array y is the
mean value of the corresponding column, row, vector, or entire input.
The output array, y, depends on the setting of the Find the mean
1-124
2-D Mean
1-125
2-D Mean
Running Operation
When you select the Running mean check box, the block tracks the
mean value of each channel in a time sequence of inputs. In this mode,
the block treats each element as a channel.
1-126
2-D Mean
Rising edge
Rising edge
• Falling edge — Triggers a reset operation when the Rst input does
one of the following:
- Falls from a positive value to a negative value or zero
- Falls from zero to a negative value, where the fall is not a
continuation of a fall from a positive value to zero (see the following
figure)
1-127
2-D Mean
ROI Processing
To calculate the statistical value within a particular region of interest
(ROI) of the input, select the Enable ROI processing check box.
This option is only available when the Find the mean value over
parameter is set to Entire input and the Running mean check box is
not selected. ROI processing is only supported for 2-D inputs.
For more information about the format of the input to the ROI port
when the ROI is a rectangle or a line, see the Draw Shapes block
reference page.
1-128
2-D Mean
Use the Output parameter to specify the block output. The block can
output separate statistical values for each ROI or the statistical value
for all specified ROIs. This parameter is not available if, for the ROI
type parameter, you select Binary mask.
If, for the ROI type parameter, you select Rectangles or Lines, the
Output flag indicating if ROI is within image bounds check box
appears in the dialog box. If you select this check box, the Flag port
appears on the block. The following tables describe the Flag port output
based on the block parameters.
Flag Description
Port
Output
0 ROI is completely outside the input image.
1 ROI is completely or partially inside the input image.
Flag Description
Port
Output
0 All ROIs are completely outside the input image.
1 At least one ROI is completely or partially inside the
input image.
1-129
2-D Mean
If the ROI is partially outside the image, the block only computes the
statistical values for the portion of the ROI that is within the image.
If, for the ROI type parameter, you select Label matrix, the Output
flag indicating if input label numbers are valid check box appears
in the dialog box. If you select this check box, the Flag port appears on
the block. The following tables describe the Flag port output based
on the block parameters.
Flag Description
Port
Output
0 Label number is not in the label matrix.
1 Label number is in the label matrix.
Flag Description
Port
Output
0 None of the label numbers are in the label matrix.
1 At least one of the label numbers is in the label matrix.
1-130
2-D Mean
You can set the accumulator and output data types in the block dialog,
as discussed in “Dialog Box” on page 1-131.
Dialog The Main pane of the Mean block dialog appears as follows.
Box
1-131
2-D Mean
Running mean
Enables running operation when selected.
Reset port
Specify the reset event that causes the block to reset the running
mean. The sample time of the input to the Rst port must be a
positive integer multiple of the input sample time. This parameter
appears only when you select the Running mean check box. For
more information, see “Resetting the Running Mean” on page
1-126.
1-132
2-D Mean
1-133
2-D Mean
When you select either of these check boxes, the Flag port appears
on the block. For a description of the Flag port output, see the
tables in “ROI Processing” on page 1-128.
The Data Types pane of the Mean block dialog appears as follows.
1-134
2-D Mean
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
Accumulator data type
Specify the accumulator data type. See “Fixed-Point Data Types”
on page 1-130 for illustrations depicting the use of the accumulator
data type in this block. You can set this parameter to:
1-135
2-D Mean
See “Specify Data Types Using Data Type Assistant” for more
information.
Output data type
Specify the output data type. See “Fixed-Point Data Types” on
page 1-130 for illustrations depicting the use of the output data
type in this block. You can set it to:
• A rule that inherits a data type, for example, Inherit: Same
as accumulator
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Minimum
Specify the minimum value that the block should output. The
default value, [], is equivalent to -Inf. Simulink software uses
this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
1-136
2-D Mean
Maximum
Specify the maximum value that the block should output. The
default value, [], is equivalent to Inf. Simulink software uses
this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Example
The ex_vision_2dmean calculates the mean value within two ROIs.
1-137
2-D Mean (To Be Removed)
Library Statistics
Description
Note This 2-D Mean block will be removed in a future release. It uses
the zero-based, [row column] coordinate system. It is recommended that
you replace this block with the updated 2-D Mean block that uses the
one-based, [x y] coordinate system.
1-138
2-D Median
Library Statistics
visionstatistics
Description The 2-D Median block computes the median value of each row or column
of the input, along vectors of a specified dimension of the input, or of the
entire input. The median of a set of input values is calculated as follows:
For a given input u, the size of the output array y depends on the setting
of the Find the median value over parameter. For example, consider
a 3-dimensional input signal of size M-by-N-by-P:
1-139
2-D Median
The accumulator and output data types and scalings are used for
fixed-point signals when M is even. The result of the sum performed
while calculating the average of the two central rows of the input matrix
1-140
2-D Median
is stored in the accumulator data type and scaling. The total result of
the average is then put into the output data type and scaling.
The accumulator and product output parameters are used for complex
fixed-point inputs. The sum of the squares of the real and imaginary
parts of such an input are formed before the input elements are sorted,
as described in Description. The results of the squares of the real
and imaginary parts are placed into the product output data type
and scaling. The result of the sum of the squares is placed into the
accumulator data type and scaling.
For fixed-point inputs that are both complex and have even M, the data
types are used in all of the ways described. Therefore, in such cases, the
accumulator type is used in two different ways.
Dialog The Main pane of the 2–D Median block dialog appears as follows.
Box
1-141
2-D Median
Sort algorithm
Specify whether to sort the elements of the input using a Quick
sort or an Insertion sort algorithm.
Find the median value over
Specify whether to find the median value along rows, columns,
entire input, or the dimension specified in the Dimension
parameter. For more information, see Description.
Dimension
Specify the dimension (one-based value) of the input signal, over
which the median is computed. The value of this parameter
cannot exceed the number of dimensions in the input signal. This
1-142
2-D Median
parameter is only visible when the Find the median value over
parameter is set to Specified dimension.
The Data Types pane of the 2-D Median block dialog appears as follows.
1-143
2-D Median
Rounding mode
Select the Rounding mode for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-140 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type
in this block. You can set it to:
• A rule that inherits a data type, for example, Inherit: Same
as input
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Accumulator data type
Specify the accumulator data type. See “Fixed-Point Data Types”
on page 1-140 for illustrations depicting the use of the accumulator
data type in this block. You can set this parameter to:
• A rule that inherits a data type, for example, Inherit: Same
as product output
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
1-144
2-D Median
See “Specify Data Types Using Data Type Assistant” for more
information.
Output data type
Specify the output data type. See “Fixed-Point Data Types” on
page 1-140 for illustrations depicting the use of the output data
type in this block. You can set it to:
• A rule that inherits a data type, for example, Inherit: Same
as accumulator
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
Minimum
Specify the minimum value that the block should output. The
default value, [], is equivalent to -Inf. Simulink software uses
this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
Maximum
Specify the maximum value that the block should output. The
default value, [], is equivalent to Inf. Simulink software uses
this value to perform:
• Simulation range checking (see “Signal Ranges”)
• Automatic scaling of fixed-point data types
1-145
2-D Median
1-146
2-D Median
1-147
2-D Minimum
Library Statistics
visionstatistics
Description The 2-D Minimum block identifies the value and/or position of the
smallest element in each row or column of the input, or along a specified
dimension of the input. The 2-D Minimum block can also track the
minimum values in a sequence of inputs over a period of time.
The 2-D Minimum block supports real and complex floating-point,
fixed-point, and Boolean inputs. Real fixed-point inputs can be either
signed or unsigned, while complex fixed-point inputs must be signed.
The output data type of the minimum values match the data type of
the input. The block outputs double index values, when the input is
double, and uint32 otherwise.
Port Description
Complex
Port Input/Output Supported Data Types Values
Supported
Input Scalar, vector or matrix of • Double-precision floating point Yes
intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Rst Scalar value Boolean No
1-148
2-D Minimum
Complex
Port Input/Output Supported Data Types Values
Supported
Val Minimum value output Same as Input port Yes
based on the “Value Mode”
on page 1-149
Idx One-based output location of Same as Input port No
the minimum value based
on the “Index Mode” on page
1-150
Value Mode
When you set the Mode parameter to Value, the block computes the
minimum value in each row, column, entire input, or over a specified
dimension. The block outputs each element as the minimum value in the
corresponding column, row, vector, or entire input. The output depends
on the setting of the Find the minimum value over parameter. For
example, consider a 3-dimensional input signal of size M-by-N-by-P:
1-149
2-D Minimum
For complex inputs, the block selects the value in each row or column of
the input, along vectors of a specified dimension of the input, or of the
entire input that has the minimum magnitude squared as shown below.
2 2
For complex value u a bi , the magnitude squared is a b .
Index Mode
When you set the Mode parameter to Index, the block computes the
minimum value in each row or column of the input, along vectors of a
specified dimension of the input, or of the entire input, and outputs the
index array I. Each element in I is an integer indexing the minimum
value in the corresponding column, row, vector, or entire input. The
output I depends on the setting of the Find the minimum value
over parameter. For example, consider a 3-dimensional input signal
of size M-by-N-by-P:
1-150
2-D Minimum
When a minimum value occurs more than once, the computed index
corresponds to the first occurrence. For example, when the input is the
column vector [-1 2 3 2 -1]', the computed one-based index of the
minimum value is 1 rather than 5 when Each column is selected.
1-151
2-D Minimum
Running Mode
When you set the Mode parameter to Running, the block tracks the
minimum value of each channel in a time sequence of M-by-N inputs.
In this mode, the block treats each element as a channel.
Rising edge
Rising edge
• Falling edge — Triggers a reset operation when the Rst input does
one of the following:
- Falls from a positive value to a negative value or zero
1-152
2-D Minimum
ROI Processing
To calculate the statistical value within a particular region of interest
(ROI) of the input, select the Enable ROI processing check box. This
applies to any mode other than the running mode and when you set the
Find the minimum value over parameter to Entire input and you
select the Enable ROI processing check box. ROI processing applies
only for 2-D inputs.
You can specify a rectangle, line, label matrix, or binary mask ROI type.
1-153
2-D Minimum
Flag Description
Port
Output
0 ROI is completely outside the input image.
1 ROI is completely or partially inside the input image.
Flag Description
Port
Output
0 All ROIs are completely outside the input image.
1 At least one ROI is completely or partially inside the
input image.
If the ROI is partially outside the image, the block only computes the
statistical values for the portion of the ROI that is within the image.
1-154
2-D Minimum
Flag Description
Port
Output
0 Label number is not in the label matrix.
1 Label number is in the label matrix.
Flag Description
Port
Output
0 None of the label numbers are in the label matrix.
1 At least one of the label numbers is in the label matrix.
1-155
2-D Minimum
Dialog The Main pane of the 2-D Minimum dialog box appears as shown in
Box the following figure.
Mode
Specify the block’s mode of operation:
• Value and Index — Output both the value and the index
location.
1-156
2-D Minimum
For the Value, Index, and Value and Index modes, the 2-D
Minimum block produces identical results as the MATLAB min
function when it is called as [y I] = min(u,[],D), where u and
y are the input and output, respectively, D is the dimension, and
I is the index.
Find the minimum value over
Specify whether the block should find the minimum of the entire
input each row, each column, or dimensions specified by the
Dimension parameter.
Reset port
Specify the reset event that causes the block to reset the running
minimum. The rate of the reset signal must be a positive integer
multiple of the rate of the data signal input. This parameter
appears only when you set the Mode parameter to Running. For
information about the possible values of this parameter, see
“Resetting the Running Minimum” on page 1-152.
Dimension
Specify the dimension (one-based value) of the input signal, over
which the minimum is computed. The value of this parameter
cannot exceed the number of dimensions in the input signal. This
parameter applies only when you set the Find the minimum
value over parameter to Specified dimension.
Enable ROI processing
Select this check box to calculate the statistical value within a
particular region of each image. This parameter applies only
1-157
2-D Minimum
when you set the Find the minimum value over parameter to
Entire input, and the block is not in running mode.
ROI type
Specify the type of ROI you want to use. Your choices are
Rectangles, Lines, Label matrix, or Binary mask.
When you set this parameter to Label matrix, the Label and
Label Numbers ports appear on the block and the Output
flag indicating if input label numbers are valid check box
appears in the dialog box. If you select this check box, the Flag
port appears on the block.
1-158
2-D Minimum
1-159
2-D Minimum
Note The parameters on the Data Types pane are only used for
complex fixed-point inputs. The sum of the squares of the real and
imaginary parts of such an input are formed before a comparison is
made, as described in “Value Mode” on page 1-149. The results of the
squares of the real and imaginary parts are placed into the product
output data type. The result of the sum of the squares is placed into
the accumulator data type. These parameters are ignored for other
types of inputs.
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 1-155 and “Multiplication Data Types” for
illustrations depicting the use of the product output data type
in this block. You can set it to:
• A rule that inherits a data type, for example, Inherit: Same
as input
• An expression that evaluates to a valid data type, for example,
fixdt([],16,0)
See “Specify Data Types Using Data Type Assistant” for more
information.
1-160
2-D Minimum
See “Specify Data Types Using Data Type Assistant” for more
information.
Examples
1-161
2-D Minimum
1-162
2-D Minimum (To Be Removed)
Library vipobslib
Description
Note This 2-D Minimum block will be removed in a future release. It
uses the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated 2-D Minimum block that
uses the one-based, [x y] coordinate system.
1-163
2-D Standard Deviation
Library Statistics
visionstatistics
Description The Standard Deviation block computes the standard deviation of each
row or column of the input, along vectors of a specified dimension of the
input, or of the entire input. The Standard Deviation block can also
track the standard deviation of a sequence of inputs over a period of
time. The Running standard deviation parameter selects between
basic operation and running operation.
Port Description
1-164
2-D Standard Deviation
Binary Mask:
• Boolean
Label • 8-, 16-, and 32-bit unsigned integers
Label • 8-, 16-, and 32-bit unsigned integers
Numbers
Output • Double-precision floating point
• Single-precision floating point
Flag • Boolean
Basic Operation
When you do not select the Running standard deviation check box,
the block computes the standard deviation of each row or column of
the input, along vectors of a specified dimension of the input, or of the
entire input at each individual sample time, and outputs the array y.
Each element in y contains the standard deviation of the corresponding
column, row, vector, or entire input. The output y depends on the
setting of the Find the standard deviation value over parameter.
For example, consider a 3-dimensional input signal of size M-by-N-by-P:
1-165
2-D Standard Deviation
For purely real or purely imaginary inputs, the standard deviation of the
jth column of an M-by-N input matrix is the square root of its variance:
M
2
∑ uij − j
i=1
yj = j = 1≤ j≤ N
M −1
1-166
2-D Standard Deviation
For complex inputs, the output is the total standard deviation, which
equals the square root of the total variance, or the square root of the
sum of the variances of the real and imaginary parts. The standard
deviation of each column in an M-by-N input matrix is given by:
j = 2j,Re + 2j,Im
Note The total standard deviation does not equal the sum of the real
and imaginary standard deviations.
Running Operation
When you select the Running standard deviation check box, the
block tracks the standard deviation of successive inputs to the block. In
this mode, the block treats each element as a channel.
1-167
2-D Standard Deviation
• Falling edge — Triggers a reset operation when the Rst input does
one of the following:
- Falls from a positive value to a negative value or zero
- Falls from zero to a negative value, where the fall is not a
continuation of a fall from a positive value to zero (see the following
figure)
Rising edge
Rising edge
1-168
2-D Standard Deviation
1-169
2-D Standard Deviation
appears in the dialog box. If you select this check box, the Flag port
appears on the block. The following tables describe the Flag port output
based on the block parameters.
Flag Description
Port
Output
0 ROI is completely outside the input image.
1 ROI is completely or partially inside the input image.
Flag Description
Port
Output
0 All ROIs are completely outside the input image.
1 At least one ROI is completely or partially inside the
input image.
If the ROI is partially outside the image, the block only computes the
statistical values for the portion of the ROI that is within the image.
If, for the ROI type parameter, you select Label matrix, the Output
flag indicating if input label numbers are valid check box appears
in the dialog box. If you select this check box, the Flag port appears on
the block. The following tables describe the Flag port output based
on the block parameters.
1-170
2-D Standard Deviation
Flag Description
Port
Output
0 Label number is not in the label matrix.
1 Label number is in the label matrix.
Flag Description
Port
Output
0 None of the label numbers are in the label matrix.
1 At least one of the label numbers is in the label matrix.
1-171
2-D Standard Deviation
Dialog
Box
1-172
2-D Standard Deviation
Dimension
Specify the dimension (one-based value) of the input signal,
over which the standard deviation is computed. The value of
this parameter cannot exceed the number of dimensions in the
input signal. This parameter is only visible when the Find the
standard deviation value over parameter is set to Specified
dimension.
Enable ROI Processing
Select this check box to calculate the statistical value within a
particular region of each image. This parameter is only available
when the Find the standard deviation value over parameter
is set to Entire input, and the block is not in running mode.
ROI type
Specify the type of ROI you want to use. Your choices are
Rectangles, Lines, Label matrix, or Binary mask.
ROI portion to process
Specify whether you want to calculate the statistical value for
the entire ROI or just the ROI perimeter. This parameter is only
visible if, for the ROI type parameter, you specify Rectangles.
Output
Specify the block output. The block can output a vector of separate
statistical values for each ROI or a scalar value that represents
the statistical value for all the specified ROIs. This parameter is
not available if, for the ROI type parameter, you select Binary
mask.
Output flag
When you select either of these check boxes, the Flag port appears
on the block. For a description of the Flag port output, see the
tables in “ROI Processing” on page 1-169.
1-173
2-D Standard Deviation
Example
The ex_vision_2dstd calculates the standard deviation value within
two ROIs.
1-174
2-D Standard Deviation (To Be Removed)
Library Statistics
Description
1-175
2-D Variance
Library Statistics
visionstatistics
Description The 2-D Variance block computes the unbiased variance of each row
or column of the input, along vectors of a specified dimension of the
input, or of the entire input. The 2-D Variance block can also track the
variance of a sequence of inputs over a period of time. The Running
variance parameter selects between basic operation and running
operation.
Port Description
1-176
2-D Variance
Binary Mask:
• Boolean
Label • 8-, 16-, and 32-bit unsigned integers
Label • 8-, 16-, and 32-bit unsigned integers
Numbers
Output • Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed integers
• 8-, 16-, and 32-bit unsigned integers
Flag • Boolean
Basic Operation
When you do not select the Running variance check box, the block
computes the variance of each row or column of the input, along vectors
of a specified dimension of the input, or of the entire input at each
individual sample time, and outputs the array y. Each element in y is
the variance of the corresponding column, row, vector, or entire input.
The output y depends on the setting of the Find the variance value
1-177
2-D Variance
1-178
2-D Variance
2
M N
M N
uij
i1 j 1
uij
2
i1 j 1
M*N
y 2
M * N 1
1-179
2-D Variance
2 Re2 Im 2
Running Operation
When you select the Running variance check box, the block tracks
the variance of successive inputs to the block. In this mode, the block
treats each element as a channel.
1-180
2-D Variance
• Falling edge — Triggers a reset operation when the Rst input does
one of the following:
- Falls from a positive value to a negative value or zero
- Falls from zero to a negative value, where the fall is not a
continuation of a fall from a positive value to zero (see the following
figure)
Rising edge
Rising edge
ROI Processing
To calculate the statistical value within a particular region of interest
(ROI) of the input, select the Enable ROI processing check box. This
option is only available when the Find the variance value over
1-181
2-D Variance
Use the Output parameter to specify the block output. The block can
output separate statistical values for each ROI or the statistical value
for all specified ROIs. This parameter is not available if, for the ROI
type parameter, you select Binary mask.
If, for the ROI type parameter, you select Rectangles or Lines, the
Output flag indicating if ROI is within image bounds check box
appears in the dialog box. If you select this check box, the Flag port
appears on the block. The following tables describe the Flag port output
based on the block parameters.
1-182
2-D Variance
Flag Description
Port
Output
0 ROI is completely outside the input image.
1 ROI is completely or partially inside the input image.
Flag Description
Port
Output
0 All ROIs are completely outside the input image.
1 At least one ROI is completely or partially inside the
input image.
If the ROI is partially outside the image, the block only computes the
statistical values for the portion of the ROI that is within the image.
If, for the ROI type parameter, you select Label matrix, the Output
flag indicating if input label numbers are valid check box appears
in the dialog box. If you select this check box, the Flag port appears on
the block. The following tables describe the Flag port output based
on the block parameters.
Flag Description
Port
Output
0 Label number is not in the label matrix.
1 Label number is in the label matrix.
1-183
2-D Variance
Flag Description
Port
Output
0 None of the label numbers are in the label matrix.
1 At least one of the label numbers is in the label matrix.
2
uij
2
uij Accumulator or
Input-squared
∑ ∑ uij
Input product Accumulator 2
data type MAGNITUDE data type
ADDER
data type 2 ∑ ∑ uij
SQUARED ∑ ∑ uij −
M*N
2
∑ ∑ uij Accumulator
uij ∑ ∑ uij Accumulator or data type
Input-sum-squared SUBTRACTOR yi
Input Accumulator product
data type data type MAGNITUDE data type
ADDER Output
SQUARED data type
DIVIDER
DIVIDER
Accumulator
data type
Accumulator 2
data type ∑ ∑ uij
M*N M*N M * N −1
1-184
2-D Variance
Dialog The Main pane of the Variance block dialog appears as follows.
Box
1-185
2-D Variance
Running variance
Enables running operation when selected.
1-186
2-D Variance
Reset port
Specify the reset event that causes the block to reset the running
variance. The sample time of the input to the Rst port must
be a positive integer multiple of the input sample time. This
parameter appears only when you select the Running variance
check box. For more information, see “Resetting the Running
Variance” on page 1-180
Find the variance value over
Specify whether to find the variance along rows, columns, entire
input, or the dimension specified in the Dimension parameter.
For more information, see “Basic Operation” on page 1-177.
Dimension
Specify the dimension (one-based value) of the input signal, over
which the variance is computed. The value of this parameter
cannot exceed the number of dimensions in the input signal. This
parameter is only visible when the Find the variance value
over parameter is set to Specified dimension.
Enable ROI Processing
Select this check box to calculate the statistical value within a
particular region of each image. This parameter is only available
when the Find the variance value over parameter is set to
Entire input, and the block is not in running mode.
ROI type
Specify the type of ROI you want to use. Your choices are
Rectangles, Lines, Label matrix, or Binary mask.
1-187
2-D Variance
When you select either of these check boxes, the Flag port appears
on the block. For a description of the Flag port output, see the
tables in “ROI Processing” on page 1-181.
The Data Types pane of the Variance block dialog appears as follows.
1-188
2-D Variance
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
1-189
2-D Variance
Input-squared product
Use this parameter to specify how to designate the input-squared
product word and fraction lengths:
• When you select Same as 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 input-squared
product, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the input-squared product.
This block requires power-of-two slope and a bias of zero.
Input-sum-squared product
Use this parameter to specify how to designate the
input-sum-squared product word and fraction lengths:
• When you select Same as input-squared product, these
characteristics match those of the input-squared product.
• When you select Binary point scaling, you can enter the
word length and the fraction length of the input-sum-squared
product, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the input-sum-squared
product. This block requires power-of-two slope and a bias of
zero.
Accumulator
Use this parameter to specify the accumulator word and fraction
lengths resulting from a complex-complex multiplication in the
block:
1-190
2-D Variance
1-191
2-D Variance
Example
The ex_vision_2dvar calculates the variance value within two ROIs.
1-192
2-D Variance (To Be Removed)
Library Statistics
Description
Note This 2-D Variance block will be removed in a future release. It
uses the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated 2-D Variance block that
uses the one-based, [x y] coordinate system.
1-193
Apply Geometric Transformation
Port Description
Image M-by-N or M-by-N-by-P input matrix. M: Number of rows in the image.
N: Number of columns in the image.
P: Number of color planes in the image.
TForm When you set the Transformation matrix source parameter to Input port,
the TForm input port accepts:
Q: Number of transformations.
When you specify multiple transforms in a single matrix, each transform is
applied separately to the original image. If the individual transforms produce
an overlapping area, the result of the transform in the last row of the matrix is
overlaid on top.
ROI When you set the ROI source parameter to Input port, the ROI input port
accepts:
• 4-element vector rectangle ROI.
• 2L-element vector polygon ROI.
1-194
Apply Geometric Transformation
Port Description
Transformations
The size of the transformation matrix will dictate the transformation
type.
Affine Transformation
⎧ xˆ = xh1 + yh2 + h3
⎨
⎩ yˆ = xh4 + yh5 + h6
where h1, h2, ... h6 are transformation coefficients.
If you use one transformation, the transformation coefficients must be
arranged as a 3-by-2 matrix as in:
h1 h4
H h2 h5
h3 h6
or in a 1-by-6 vector as in H h1 h2 h3 h4 h5 h6 .
If you use more than one transformation, the transformation coefficients
must be arranged as a Q-by-6 matrix, where each row has the
1-195
Apply Geometric Transformation
⎧ ˆ xh1 + yh2 + h3
⎪ x = xh + yh + h
⎪ 7 8 9
⎨
xh
⎪ yˆ = 4 + yh 5 + h6
⎪⎩ xh7 + yh8 + h9
where h1, h2, ... h9 are transformation coefficients.
If you use one transformation, the transformation coefficients must be
arranged as a 3-by-3 matrix as in:
h1 h4 h7
H h2 h5 h8
h3 h6 h9
1-196
Apply Geometric Transformation
Dialog Box
The Main pane of the Apply Geometric Transformation dialog box
appears as shown in the following figure.
1-197
Apply Geometric Transformation
1-198
Apply Geometric Transformation
1-199
Apply Geometric Transformation
Number of
Transformation Region of Interest
Matrices
One You can apply the transformation on the entire image, single ROI or
transformation multiple ROIs.
matrix
Multiple • You can apply multiple transformation matrices on one ROI or on
transformation the entire image. The transformations are done in the order they
matrices are entered in the TForm.
• You can apply multiple transformation matrices on multiple
ROIs. Each transformation matrix is applied to one ROI. The first
transformation matrix specified is applied to the first ROI specified.
The second transformation matrix is applied to the second ROI
specified, and so on. The number of transformation matrices must
be equal to the number of ROIs.
ROI source
Specify the source for the region of interest (ROI), either Specify via
dialog or Input port. This appears when you set the Process pixels
in parameter to either Rectangle ROI, or Polygon ROI.
Location and size of rectangle ROI [x y width height]
Specify a 4-element vector or an R-by-4 matrix , (where R represents the
number of ROIs). This parameter appears when you set the Process
pixels in parameter to Rectangle ROI.
Specify the rectangle by its top-left corner and size in width and height.
If you specify one ROI, it must be a 4-element vector of format [x y width
height]. If you specify more than one ROI, it must be an R-by-4 matrix,
such that each row’s format is [x y width height].
Vertices of polygon ROI [x1 y1 x2 y2 ... xL yL]
Specify a 2L-element vector or an R-by-2L matrix, (where R represents
the number of ROIs and L is the number of vertices in a polygon). This
parameter appears when you set the Process pixels in parameter
to Polygon ROI.
1-200
Apply Geometric Transformation
1-201
Apply Geometric Transformation
1 Add two Constant blocks for the input image and the transformation
matrix. Set the Constant value parameters for the constant blocks
as follows:
• for the input image, "checker_board", and
• for the transformation matrix,[1 0 0; .4 1 0; 0 0 1]
2 Add two Video Viewer blocks, connecting one directly to the input
image output port, and the other one to the Apply Geometric
Transformation output port.
1-202
Apply Geometric Transformation
4 Add two Video Viewer blocks, connecting one directly to the Constant
block containing the input image. The other, to the Apply Geometric
Transformation output port.
References [1] George Wolberg, “Digital Image Warping”, IEEE Computer Society
Press, 3rd edition, 1994.
Richard Hartley and Andrew Zisserman, “Multiple View Geometry in
Computer Vision“, Cambridge University Press, 2nd edition, 2003.
Supported
Data
Types
1-203
Apply Geometric Transformation
1-204
Apply Geometric Transformation (To Be Removed)
Description
Note This Apply Geometric Transformation block will be removed
in a future release. It uses the zero-based, [row column] coordinate
system. It is recommended that you replace this block with the updated
Apply Geometric Transformation block that uses the one-based, [x y]
coordinate system.
1-205
Autothreshold
Library Conversions
visionconversions
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of intensity • Double-precision floating No
values point
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed
integer
• 8-, 16-, and 32-bit unsigned
integer
BW Scalar, vector, or matrix that Boolean No
represents a binary image
Th Threshold value Same as I port No
EMetric Effectiveness metric Same as I port No
1-206
Autothreshold
If you clear the Scale threshold check box, the block uses the
threshold value computed by Otsu’s method to convert intensity images
1-207
Autothreshold
into binary images. If you select the Scale threshold check box, the
Threshold scaling factor appears in the dialog box. Enter a scalar
value. The block multiplies this scalar value with the threshold value
computed by Otsu’s method and uses the result as the new threshold
value.
In this diagram, DT means data type. You can set the product,
accumulator, quotient, and effectiveness metric data types in the block
mask.
1-208
Autothreshold
Dialog The Main pane of the Autothreshold dialog box appears as shown in
Box the following figure.
Thresholding operator
Specify the condition the block places on the input matrix values.
If you select > or <=, the block outputs 0 or 1 depending on
1-209
Autothreshold
1-210
Autothreshold
The Data Types pane pane of the Autothreshold dialog box appears as
follows. You can use the default fixed-point parameters if your input
has a word length less than or equal to 16.
Rounding mode
Select the rounding mode for fixed-point operations. This
parameter does not apply to the Cast to input DT step shown in
1-211
Autothreshold
1-212
Autothreshold
Accumulator 1, 2, 3, 4
1-213
Autothreshold
Quotient
Choose how to specify the word length and fraction length of the
quotient data type:
• When you select Specify word length, you can enter the
word length of the quotient values in bits. The block sets the
fraction length to give you the best precision.
• When you select Binary point scaling, you can enter the
word length and the fraction length of the quotient, in bits.
• When you select Slope and bias scaling, you can enter the
word length in bits and the slope of the quotient. The bias of all
signals in the Computer Vision System Toolbox software is 0.
Eff Metric
Choose how to specify the word length and fraction length of the
effectiveness metric data type. This parameter is only visible if,
on the Main tab, you select the Output effectiveness metric
check box.
• When you select Specify word length, you can enter the word
length of the effectiveness metric values, in bits. The block sets
the fraction length to give you the best precision.
• When you select Binary point scaling, you can enter the
word length and the fraction length of the effectiveness metric
in bits.
• When you select Slope and bias scaling, you can enter the
word length in bits and the slope of the effectiveness metric.
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.
1-214
Autothreshold
ex_vision_autothreshold
1-215
Blob Analysis
Library Statistics
visionstatistics
Description Use the Blob Analysis block to calculate statistics for labeled regions
in a binary image. The block returns quantities such as the centroid,
bounding box, label matrix, and blob count. The Blob Analysis block
supports input and output variable size signals.
For information on pixel and spatial coordinate system definitions, see
“Expressing Image Locations” in the Image Processing Toolbox User
Guide. Use the Selector block from the Simulink, to select certain blobs
based on their statistics.
Port Descriptions
1-216
Blob Analysis
Dialog Box
The Main pane of the Blob Analysis dialog box appears as shown in the
following figure. Use the check boxes to specify the statistics values
you want the block to output. For a full description of each of these
statistics, see the regionprops function reference page in the Image
Processing Toolbox documentation.
1-217
Blob Analysis
Area
Select this check box to output a vector that represents the
number of pixels in labeled regions
1-218
Blob Analysis
Centroid
Select this check box to output an M-by-2 matrix of [x y] centroid
coordinates. The rows represent the coordinates of the centroid of
each region, where M represents the number of blobs.
Example: Suppose there are two blobs, where the row and column
coordinates of their centroids are x1, y1 and x2, y2, respectively.
The block outputs:
x1 y1
x y2
2
at the Centroid port.
Bounding box
Select this check box to output an M-by-4 matrix of [x y width
height] bounding boxes. The rows represent the coordinates of
each bounding box, where M represents the number of blobs.
Example: Suppose there are two blobs, where x and y define the
location of the upper-left corner of the bounding box, and w,
h define the width and height of the bounding box. The block
outputs
x1 y1 w1 h1
x y2 w2 h2
2
at the BBox port.
Major axis length
Select this check box to output a vector with the following
characteristics:
• Represents the lengths of the major axes of ellipses
• Has the same normalized second central moments as the
labeled regions
1-219
Blob Analysis
π π
− and
2 2
Eccentricity
Select this check box to output a vector that represents the
eccentricities of ellipses that have the same second moments as
the region
Equivalent diameter squared
Select this check box to output a vector that represents the
equivalent diameters squared
Extent
Select this check box to output a vector that represents the results
of dividing the areas of the blobs by the area of their bounding
boxes
Perimeter
Select this check box to output an N-by-1 vector of the perimeter
lengths, in pixels, of each blob, where N is the number of blobs.
Statistics output data type
Specify the data type of the outputs at the Centroid, MajorAxis,
MinorAxis, Orientation, Eccentricity, Equivalent diameter
squared, and Extent ports. If you select Fixed-point, the
block cannot calculate the major axis, minor axis, orientation, or
eccentricity and the associated check boxes become unavailable.
1-220
Blob Analysis
Connectivity
Define which pixels connect to each other. If you want to connect
pixels located on the top, bottom, left, and right, select 4. If you
want to connect pixels to the other pixels on the top, bottom, left,
right, and diagonally, select 8. For more information about this
parameter, see the Label block reference page.
The block calculates the distance between the center of each pixel
(marked by the black dots) and estimates the perimeter to be 22.
The next figure illustrates how the block calculates the perimeter
of a blob when you set the Connectivity parameter to 8.
1-221
Blob Analysis
The block takes a different path around the blob and estimates
the perimeter to be 18 + 2 2 .
Output label matrix
Select this check box, to output the label matrix at the Label port.
The pixels equal to 0 represent the background. The pixels equal
to 1 represent the first object. The pixels equal to 2 represent the
second object, and so on.
The Blob Properties pane of the Blob Analysis dialog box appears
as shown in the following figure.
1-222
Blob Analysis
1-223
Blob Analysis
on both the value of this parameter, and on the size of the input
image. The number of blobs the block outputs may be limited
by the input image size.
Warn if maximum number of blobs is exceeded
Select this check box to output a warning when the number of
blobs in an image is greater than the value of Maximum number
of blobs parameter.
Output number of blobs found
Select this check box to output a scalar value that represents the
actual number of connected regions in each image at the Count
port.
Specify maximum blob area in pixels
Select this check box to enter the minimum blob area in the edit
box that appears beside the check box. The blob gets a label if
the number of pixels meets the minimum size specified. The
maximum allowable value is the maximum of uint32 data type.
This parameter is tunable.
Exclude blobs touching image border
Select this check box to exclude a labeled blob that contains at
least one border pixel.
Output blob statistics as a variable-size signal
Select this check box to output blob statistics as a variable-size
signal. Selecting this check box means that you do not need to
specify fill values.
Fill empty spaces in outputs outputs
Select this check box to fill empty spaces in the statistical vectors
with the values you specify in the Fill values parameter.
The Fill empty spaces in outputs check box does not appear
when you select the Output blob statistics as a variable-size
signal check box.
1-224
Blob Analysis
Fill values
If you enter a scalar value, the block fills all the empty spaces in
the statistical vectors with this value. If you enter a vector, it
must have the same length as the number of selected statistics.
The block uses each vector element to fill a different statistics
vector. If the empty spaces do not affect your computation, you
can deselect the Fill empty spaces in outputs check box. As a
best practice, leave this check box selected.
The Fill values parameter is not visible when you select the
Output blob statistics as a variable-size signal check box.
The Fixed-Point Data Types pane of the Blob Analysis dialog box
appears as shown in the following figure.
The parameters on the Fixed-point tab apply only when you set the
Statistics output data type parameter to Specify via Fixed-point
tab.
1-225
Blob Analysis
Rounding mode
Select the rounding mode Floor, Ceiling, Nearest or Zero for
fixed-point operations.
1-226
Blob Analysis
Overflow mode
Select the overflow mode, Wrap or Saturate for fixed-point
operations.
Product output
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. All
signals in the Computer Vision System Toolbox software have
a bias of 0.
The block places the output of the multiplier into the Product
output data type and scaling. The computation of the equivalent
diameter squared uses the product output data type. During this
computation, the block multiplies the blob area (stored in the
accumulator) by the 4/pi factor. This factor has a word length that
equals the value of Equivalent diameter squared output data
type Word length. The value of the Fraction length equals its
word length minus two. Use this parameter to specify how to
designate this product output word and fraction lengths.
Accumulator
When you select Same as product output the characteristics
match the characteristics of the product output.
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. All
1-227
Blob Analysis
1-228
Blob Analysis
The Fill empty spaces in outputs check box is not visible when
you select the Output blob statistics as a variable-size signal
check box.
Perimeter output
Choose how to specify the Word length and Fraction length of
the output at the Perimeter port:
1-229
Blob Analysis
1-230
Blob Analysis (To Be Removed)
Library Statistics
Description
Note This Blob Analysis block will be removed in a future release. It
uses the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated Blob Analysis block that
uses the one-based, [x y] coordinate system.
1-231
Block Matching
Description The Block Matching block estimates motion between two images or
two video frames using “blocks” of pixels. The Block Matching block
matches the block of pixels in frame k to a block of pixels in frame k+1
by moving the block of pixels over a search region.
Suppose the input to the block is frame k. The Block Matching block
performs the following steps:
1 The block subdivides this frame using the values you enter for the
Block size [height width] and Overlap [r c] parameters. In the
following example, the Overlap [r c] parameter is [0 0].
2 For each subdivision or block in frame k+1, the Block Matching block
establishes a search region based on the value you enter for the
Maximum displacement [r c] parameter.
3 The block searches for the new block location using either the
Exhaustive or Three-step search method.
1-232
Block Matching
Center pixel
Block
STEP 2: Establish the search region in frame k+1. STEP 3: Search for the new block location in frame k+1.
1-233
Block Matching
Complex
Port Output Supported Data Types Values
Supported
I/I1 Scalar, vector, or matrix • Double-precision floating point No
of intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned
integer
I2 Scalar, vector, or matrix Same as I port No
of intensity values
|V|^2 Matrix of velocity Same as I port No
magnitudes
V Matrix of velocity Same as I port Yes
components in complex
form
• If you select Exhaustive, the block selects the location of the block
of pixels in frame k+1 by moving the block over the search region 1
pixel at a time. This process is computationally expensive.
• If you select Three-step, the block searches for the block of pixels
in frame k+1 that best matches the block of pixels in frame k using
a steadily decreasing step size. The block begins with a step size
1-234
Block Matching
Use the Block matching criteria parameter to specify how the block
measures the similarity of the block of pixels in frame k to the block of
pixels in frame k+1. If you select Mean square error (MSE), the Block
Matching block estimates the displacement of the center pixel of the
block as the (d1 , d2 ) values that minimize the following MSE equation:
1
MSE(d1 , d2 ) = ∑ ∑[ s(n1 , n2 , k) − s(n1 + d1 , n2 + d2 , k + 1)]2
N1 × N 2 (n ,n ), ∈B
1 2
1
MAD(d1 , d2 ) = ∑ ∑| s(n1 , n2 , k) − s(n1 + d1 , n2 + d2 , k + 1)|
N1 × N 2 (n ,n ), ∈B
1 2
1-235
Block Matching
move from image to image or frame to frame. The block uses this value
to determine the size of the search region.
Use the Velocity output parameter to specify the block’s output. If you
select Magnitude-squared, the block outputs the optical flow matrix
where each element is of the form u2+v2. If you select Horizontal and
vertical components in complex form, the block outputs the optical
flow matrix where each element is of the form u + jv . The real part of
each value is the horizontal velocity component and the imaginary part
of each value is the vertical velocity component.
Fixed-Point The following diagram shows the data types used in the Block Matching
Data block for fixed-point signals.
Types
1-236
Block Matching
The result of each addition remains The result of each multiplication remains
in the accumulator data type. in the product data type.
Accumulator
data type
CAST ADDER
Input Accumulator
Accumulator data type
data type data type
You can set the accumulator and output data types in the block mask
as discussed in the next section.
1-237
Block Matching
Dialog The Main pane of the Block Matching dialog box appears as shown in
Box the following figure.
1-238
Block Matching
The Data Types pane of the Block Matching dialog box appears as
shown in the following figure.
1-239
Block Matching
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
Product output
1-240
Block Matching
1-241
Block Matching
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select Binary point scaling, you can enter the
word length of the output, in bits. The fractional length is
always 0.
• When you select Slope and bias scaling, you can enter the
word length, in bits, 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.
1-242
Block Processing
Library Utilities
visionutilities
Subsystem
The blocks inside the subsystem dictate the frame status of the input
and output signals, whether single channel or multichannel signals are
supported, and which data types are supported by this block.
1-243
Block Processing
1-244
Block Processing
Dialog The Block Processing dialog box appears as shown in the following
Box figure.
Number of inputs
Enter the number of input ports on the Block Processing block.
Add port to supply subsystem parameters
Add an input port to the block to supply subsystem parameters.
Number of outputs
Enter the number of output ports on the Block Processing block.
1-245
Block Processing
Block size
Specify the size of each submatrix in cell array format. Each
vector in the cell array corresponds to one input.
Overlap
Specify the overlap of each submatrix in cell array format. Each
vector in the cell array corresponds to the overlap of one input.
Traverse order
Determines how the block extracts submatrices from the input
matrix. If you select Row-wise, the block extracts submatrices
by moving across the rows. If you select Column-wise, the block
extracts submatrices by moving down the columns.
Open Subsystem
Click this button to open the block’s subsystem. Click-and-drag
blocks into this subsystem to define the processing operation(s)
the block performs on the submatrices.
1-246
Bottom-hat
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of • Double-precision floating point No
intensity values
• Single-precision floating point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
Nhood Matrix or vector of ones Boolean No
and zeros that represents
the neighborhood values
Output Scalar, vector, or matrix Same as I port No
that represents the
filtered image
If your input image is a binary image, for the Input image type
parameter, select Binary. If your input image is an intensity image,
select Intensity.
1-247
Bottom-hat
Dialog The Bottom-hat dialog box appears as shown in the following figure.
Box
1-248
Bottom-hat
1-249
Chroma Resampling
Library Conversions
visionconversions
Complex
Port Input/Output Supported Data Types Values
Supported
Cb Matrix that • Double-precision floating point No
represents one
• Single-precision floating point
chrominance
component of an • 8-bit unsigned integer
image
Cr Matrix that Same as Cb port No
represents one
chrominance
component of an
image
The data type of the output signals is the same as the data type of the
input signals.
1-250
Chroma Resampling
Y pixel
Cb and Cr pixel
Downsampling
If, for the Resampling parameter, you select 4:4:4 to 4:2:2,
4:4:4 to 4:2:0 (MPEG1), 4:4:4 to 4:2:0 (MPEG2),
4:4:4 to 4:1:1, 4:2:2 to 4:2:0 (MPEG1), or
4:2:2 to 4:2:0 (MPEG2), the block performs a downsampling
operation. When the block downsamples from one format to another, it
can bandlimit the input signal by applying a lowpass filter to prevent
aliasing.
If, for the Antialiasing filter parameter, you select Default, the block
uses a built-in lowpass filter to prevent aliasing.
If, for the Resampling parameter, you select 4:4:4 to 4:2:2,
4:4:4 to 4:2:0 (MPEG1), 4:4:4 to 4:2:0 (MPEG2), or
4:4:4 to 4:1:1 and, for the Antialiasing filter parameter, you select
1-251
Chroma Resampling
Upsampling
If, for the Resampling parameter, you select 4:2:2 to 4:4:4,
4:2:0 (MPEG1) to 4:2:2, 4:2:0 (MPEG1) to 4:4:4,
4:2:0 (MPEG2) to 4:2:2, 4:2:0 (MPEG2) to 4:4:4, or
4:1:1 to 4:4:4, the block performs an upsampling operation.
When the block upsamples from one format to another, it uses
interpolation to approximate the missing chrominance values. If, for
the Interpolation parameter, you select Linear, the block uses linear
interpolation to calculate the missing values. If, for the Interpolation
parameter, you select Pixel replication, the block replicates the
chrominance values of the neighboring pixels to create the upsampled
image.
1-252
Chroma Resampling
When you use the row-major functionality, you must consider the
following issues:
• When you select this check box, the signal dimensions of the Chroma
Resampling block’s input are swapped.
• All the Computer Vision System Toolbox blocks can be used to
process data that is in the row-major format, but you need to know
the image dimensions when you develop your algorithms.
For example, if you use the 2-D FIR Filter block, you need to verify
that your filter coefficients are transposed. If you are using the
Rotate block, you need to use negative rotation angles, etc.
• Only three blocks have the Input image is transposed (data
order is row major) check box. They are the Chroma Resampling,
Deinterlacing, and Insert Text blocks. You need to select this check
box to enable row-major functionality in these blocks. All other blocks
must be properly configured to process data in row-major format.
1-253
Chroma Resampling
Step 1:
Create block diagram Algorithm
blocks
Step 2:
Replace source, transpose, and
Embedded sink blocks with target source Embedded
target source and sink blocks that produce target sink
block data in row-major format block
See the DM642 EVM Video ADC and DM642 EVM Video DAC reference
pages.
1-254
Chroma Resampling
Dialog The Chroma Resampling dialog box appears as shown in the following
Box figure.
Resampling
Specify the resampling format.
Antialiasing filter
Specify the lowpass filter that the block uses to prevent aliasing.
If you select Default, the block uses a built-in lowpass filter. If
you select User-defined, the Horizontal filter coefficients
and/or Vertical filter coefficients parameters appear on the
dialog box. If you select None, the block does not filter the input
signal. This parameter is visible when you are downsampling
the chrominance values.
Horizontal filter coefficients
Enter the filter coefficients to apply to your input signal.
This parameter is visible if, for the Resampling parameter,
you select 4:4:4 to 4:2:2, 4:4:4 to 4:2:0 (MPEG1),
4:4:4 to 4:2:0 (MPEG2), or 4:4:4 to 4:1:1 and, for the
Antialiasing filter parameter, you select User-defined.
Vertical filter coefficients
Enter the filter coefficients to apply to your input signal. This
parameter is visible if, for the Resampling parameter, you
1-255
Chroma Resampling
References [1] Haskell, Barry G., Atul Puri, and Arun N. Netravali. Digital Video:
An Introduction to MPEG-2. New York: Chapman & Hall, 1996.
[3] Wang, Yao, Jorn Ostermann, Ya-Qin Zhang. Video Processing and
Communications. Upper Saddle River, NJ: Prentice Hall, 2002.
1-256
Chroma Resampling
1-257
Closing
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of intensity • Double-precision floating point No
values
• Single-precision floating point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed
integer
• 8-, 16-, and 32-bit unsigned
integer
Nhood Matrix or vector of ones and Boolean No
zeros that represents the
neighborhood values
Output Vector or matrix of intensity Same as I port No
values that represents the
closed image
The output signal has the same data type as the input to the I port.
1-258
Closing
Dialog The Closing dialog box appears as shown in the following figure.
Box
1-259
Closing
References [1] Soille, Pierre. Morphological Image Analysis. 2nd ed. New York:
Springer, 2003.
1-260
Color Space Conversion
Library Conversions
visionconversions
Description The Color Space Conversion block converts color information between
color spaces. Use the Conversion parameter to specify the color spaces
you are converting between. Your choices are R'G'B' to Y'CbCr,
Y'CbCr to R'G'B', R'G'B' to intensity, R'G'B' to HSV, HSV to
R'G'B', sR'G'B' to XYZ, XYZ to sR'G'B', sR'G'B' to L*a*b*, and
L*a*b* to sR'G'B'.
Complex
Port Input/Output Supported Data Types Values
Supported
Input / M-by-N-by-P color video signal • Double-precision floating No
Output where P is the number of color point
planes
• Single-precision floating point
• 8-bit unsigned integer
R’ Matrix that represents one Same as the Input port No
plane of the input RGB video
stream
G’ Matrix that represents one Same as the Input port No
plane of the input RGB video
stream
B’ Matrix that represents one Same as the Input port No
plane of the input RGB video
stream
Y’ Matrix that represents the luma Same as the Input port No
portion of an image
1-261
Color Space Conversion
Complex
Port Input/Output Supported Data Types Values
Supported
Cb Matrix that represents one Same as the Input port No
chrominance component of an
image
Cr Matrix that represents one Same as the Input port No
chrominance component of an
image
I’ Matrix of intensity values Same as the Input port No
H Matrix that represents the hue • Double-precision floating No
component of an image point
• Single-precision floating point
S Matrix that represents Same as the H port No
represent the saturation
component of an image
V Matrix that represents the Same as the H port No
value (brightness) component of
an image
X Matrix that represents the X Same as the H port No
component of an image
Y Matrix that represents the Y Same as the H port No
component of an image
Z Matrix that represents the Z Same as the H port No
component of an image
L* Matrix that represents the Same as the H port No
luminance portion of an image
a* Matrix that represents the a* Same as the H port No
component of an image
b* Matrix that represents the b* Same as the H port No
component of an image
1-262
Color Space Conversion
The data type of the output signal is the same as the data type of the
input signal.
Use the Image signal parameter to specify how to input and output
a color video signal. If you select One multidimensional signal, the
block accepts an M-by-N-by-P color video signal, where P is the number
of color planes, at one port. If you select Separate color signals,
additional ports appear on the block. Each port accepts one M-by-N
plane of an RGB video stream.
Note The prime notation indicates that the signals are gamma
corrected.
⎡ Y ′ ⎤ ⎡ 16 ⎤ ⎡ R′ ⎤
⎢Cb⎥ = ⎢128 ⎥ + A × ⎢ G ′ ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢⎣ Cr ⎥⎦ ⎢⎣128 ⎥⎦ ⎢⎣ B′ ⎥⎦
⎡ R′ ⎤ ⎛ ⎡ Y ′ ⎤ ⎡ 16 ⎤ ⎞
⎢ G ′ ⎥ = B × ⎜ ⎢Cb⎥ − ⎢128 ⎥ ⎟
⎢ ⎥ ⎜⎢ ⎥ ⎢ ⎥⎟
⎢⎣ B′ ⎥⎦ ⎜ ⎢ Cr ⎥ ⎢128 ⎥ ⎟
⎝⎣ ⎦ ⎣ ⎦⎠
The values in the A and B matrices are based on your choices for the
Use conversion specified by and Scanning standard parameters.
The following table summarizes the possible values:
1-263
Color Space Conversion
B ⎡1.16438356 0 1.79274107 ⎤
⎢1.16438356 -0.21324861 -0.53290933⎥
⎢ ⎥
1.1643836 0 1.5960268 ⎣⎢1.1643
38356 2.11240179 0 ⎥⎦
1.1643836 0 1.5960268
1.1643836 0.39176229 0.81296765 1.1643836 0.39176229 0.81296765
1.1643836 2.0172321 0 1.1643836 2.0172321 0
Conversion R’B’G’ to Intensity
The conversion from the R’B’G’ color space to intensity is defined by the
following equation:
⎡ R′ ⎤
intensity = [0.299 0.587 0.114 ] ⎢⎢ G ′ ⎥⎥
⎢⎣ B′ ⎥⎦
1-264
Color Space Conversion
⎧ ⎛ G ′ − B′ ⎞
⎪ ⎜ MAX − MIN ⎟ / 6, if R′ = MAX
⎪ ⎝ ⎠
⎪⎛ B′ − R′ ⎞
H = ⎨⎜ 2 + ⎟ / 6, if G ′ = MAX
⎪⎝ MAX − MIN ⎠
⎪⎛ R′ − G ′ ⎞
⎪⎜ 4 + ⎟ / 6, if B′ = MAX
⎩⎝ MAX − MIN ⎠
MAX − MIN
S=
MAX
V = MAX
Hi = ⎢⎣6 H ⎥⎦
f = 6 H − Hi
p =1− S
q = 1 − fS
t = 1 − (1 − f ) S
if Hi = 0, Rtmp = 1, Gtmp = t, Btmp = p
if Hi = 1, Rtmp = q, Gtmp = 1, Btmp = p
if Hi = 2, Rtmp = p, Gtmp = 1, Btmp = t
if Hi = 3, Rtmp = p, Gtmp = q, Btmp = 1
if Hi = 4, Rtmp = t, Gtmp = p, Btmp = 1
if Hi = 5, Rtmp = 1, Gtmp = p, Btmp = q
u = V / max( Rtmp , Gtmp , Btmp )
R′ = uRtmp
G ′ = uGtmp
B′ = uBtmp
For more information about the HSV color space, see “HSV Color Space”
in the Image Processing Toolbox documentation.
1-265
Color Space Conversion
If ′
RsRGB ′
, GsRGB ′
, BsRGB ≤ 0.03928
′
RsRGB = RsRGB / 12.92
′ GB / 12.92
GsRGB = GsR
′
BsRGB = BsRGB / 12.92
′
otherwise, if RsRGB ′
, GsRGB ′ B > 0.03928
, BsRG
2 .4
( R′ + 0.055)
RsRGB = ⎡ sRGB ⎤
⎢⎣ 1.055⎥⎦
2 .4
(G ′ + 0.055)
GsRGB = ⎡ sRGB ⎤
⎢⎣ 1.055⎥⎦
2 .4
( B′ + 0.055)
BsRGB = ⎡ sRGB ⎤
⎣⎢ 1.055⎦⎥
Then the block converts the sRGB values to XYZ values using the
following equation:
−1
⎡ RsRGB ⎤ ⎡0.41239079926596 0.35758433938388 0.18048078840183 ⎤ ⎡X⎤
⎢G ⎥ ⎢ ⎥ × ⎢⎢ Y ⎥⎥
⎢ sRGB ⎥ = ⎢0.21263900587151 0.71516867876776 0.07219231536073 ⎥
⎢⎣ BsRGB ⎥⎦ ⎢⎣0.01933081871559 0.11919477979463 0.95053215224966 ⎥⎦ ⎣⎢ Z ⎦⎥
1-266
Color Space Conversion
Then the block applies gamma correction to obtain the sR’G’B’ values.
This process is described by the following equations:
1-267
Color Space Conversion
a* = 500( f ( X X n ) − f (Y Yn ))
b* = 200( f (Y Yn ) − f ( Z Zn )),
where f (t) = t1 3 , for t > 0.008856
f (t) = 7.787t + 16 166, otherwise
X = X n ( P + a * 500)3
Y = Yn P 3
Z = Zn ( P − b * 200)3 ,
where P = (L
L * +16) / 116
1-268
Color Space Conversion
Dialog The Color Space Conversion dialog box appears as shown in the
Box following figure.
Conversion
Specify the color spaces you are converting between. Your
choices are R'G'B' to Y'CbCr, Y'CbCr to R'G'B', R'G'B' to
intensity, R'G'B' to HSV, HSV to R'G'B', sR'G'B' to XYZ,
XYZ to sR'G'B', sR'G'B' to L*a*b*, and L*a*b* to sR'G'B'.
Use conversion specified by
Specify the standard to use to convert your values between the
R’G’B’ and Y’CbCr color spaces. Your choices are Rec. 601
(SDTV) or Rec. 709 (HDTV). This parameter is only available
1-269
Color Space Conversion
[5] Berns, Roy S. Principles of Color Technology, 3rd ed. New York:
John Wiley & Sons, 2000.
1-270
Color Space Conversion
1-271
Compositing
Purpose Combine pixel values of two images, overlay one image over another,
or highlight selected pixels
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:
You can define the amount by which to scale each pixel value before
combining them using the opacity factor, X, where , 0 ≤ X ≤ 1 .
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.
1-272
Compositing
You can set the product output, accumulator, and output data types in
the block mask as discussed in the next section.
Dialog The Main pane of the Compositing dialog box appears as shown in
Box the following figure.
1-273
Compositing
1-274
Compositing
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
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 you choose Specify via dialog, the Opacity factor(s)
parameter appears on the dialog box. Use this parameter to
define the amount by which the block scales each pixel values
for input image at the Image2 port before combining them
with the pixel values of the input image at Image1 port. You
can enter a scalar value used for all pixels or a matrix of values
that is the same size as the input image at the Image2 port.
• If you choose Input port, the Factor port appears on the
block. The input to this port must be a scalar or matrix of
values as described for the Opacity factor(s) parameter. If
the input to the Image1 and Image2 ports is floating point,
the input to this port must be the same floating-point data type.
Binary mask
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).
• If you choose Specify via dialog, the Mask parameter
appears on the dialog box. Use this parameter and the location
source of the image to define which pixels are overwritten. You
1-275
Compositing
1-276
Compositing
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.
1-277
Compositing
1-278
Compositing
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.
1-279
Compositing
• 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
1-280
Compositing
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
Complex
Port Input/Output Supported Data Types Values
Supported
Image 1 M-by-N matrix of intensity • Double-precision floating No
values or an M-by-N-by-P color point
video signal where P is the
• Single-precision floating point
number of color planes
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed
integer
1-281
Compositing
Complex
Port Input/Output Supported Data Types Values
Supported
1-282
Compositing
Complex
Port Input/Output Supported Data Types Values
Supported
Location Two-element vector [x y], that • Double-precision floating No
specifies the position of the point. (Only supported
upper-left corner of the image if the input to the Image
input at port I2 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
Output Vector or matrix of intensity or Same as Image 1 port No
color values
1-283
Compositing (To Be Removed)
Purpose Combine pixel values of two images, overlay one image over another,
or highlight selected pixels
Description
1-284
Contrast Adjustment
Number of pixels
1500
These values are
scaled to lower
output limit.
Pixel value
50 100 150 200 250
Number of pixels
1000
Pixel value
25 50 75 100 125
1-285
Contrast Adjustment
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of • Double-precision floating point No
intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
Output Scalar, vector, or matrix Same as I port No
of intensity values or a
scalar, vector, or matrix
that represents one plane
of the RGB video stream
1-286
Contrast Adjustment
If you select Full input data range [min max], uses the
minimum input value as the lower input limit and the maximum
input value as the upper input limit.
If you select User-defined, the Range [low high] parameter
associated with this option appears. Enter a two-element vector of
scalar values, where the first element corresponds to the lower input
limit and the second element corresponds to the upper input limit.
If you select Range determined by saturating outlier pixels,
the Percentage of pixels to saturate [low high] (in %), Specify
number of histogram bins (used to calculate the range when
outliers are eliminated), and Number of histogram bins
parameters appear on the block. The block uses these parameter
values to calculate the input limits in this three-step process:
3 Find the lower input limit such that the percentage of pixels with
values smaller than the lower limit is at most the value of the first
element of the Percentage of pixels to saturate [low high] (in
%) parameter. Similarly, find the upper input limit such that the
percentage of pixels with values greater than the upper limit is at
least the value of the second element of the parameter.
Output limits
Use the Adjust pixel values to parameter to specify the upper and
lower output limits.
If you select Full data type range, the block uses the minimum
value of the input data type as the lower output limit and the
maximum value of the input data type as the upper out
1-287
Contrast Adjustment
If any input pixel has a NAN value, the block maps the pixels with valid
numerical values according to the user-specified method. It maps the
NAN pixels to the lower limit of the Adjust pixels values to parameter.
Examples
See “Adjust the Contrast of Intensity Images” in the Computer Vision
System Toolbox User’s Guide.
1-288
Contrast Adjustment
Dialog The Contrast Adjustment dialog box appears as shown in the following
Box figure.
1-289
Contrast Adjustment
1-290
Contrast Adjustment
The Data Types pane of the Contrast Adjustment dialog box appears
as shown in the following figure.
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
1-291
Contrast Adjustment
Product 1
The product output type when the block calculates the ratio
between the input data range and the number of histogram bins.
Accumulator
data type
MULTIPLIER
sfix8_En7 Product output
data type
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.
Product 2
The product output type when the block calculates the bin location
of each input value.
Accumulator
data type
MULTIPLIER
sfix8_En7 Product output
data type
1-292
Contrast Adjustment
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.
This parameter is visible if, for the Adjust pixel values from
parameter, you select Range determined by saturating
outlier pixels.
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.
1-293
Corner Detection
Description
The Corner Detection block finds corners in an image using the Harris
corner detection (by Harris & Stephens), minimum eigenvalue (by Shi
& Tomasi), or local intensity comparison (Features from Accelerated
Segment Test, FAST by Rosten & Drummond) method. The block finds
the corners in the image based on the pixels that have the largest corner
metric values.
For the most accurate results, use the “Minimum Eigenvalue Method”
on page 1-295. For the fastest computation, use the “Local Intensity
Comparison” on page 1-296. For the trade-off between accuracy and
computation, use the “Harris Corner Detection Method” on page 1-296.
Port Description
1-294
Corner Detection
⎡ A C⎤
M=⎢ ⎥
⎣ C B⎦
A = ( I x )2 ⊗ w
B = ( I y )2 ⊗ w
C = ( I x I y )2 ⊗ w
where I x and I y are the gradients of the input image, I, in the x and y
direction, respectively. The ⊗ symbol denotes a convolution operation.
1-295
Corner Detection
R = AB − C 2 − k( A + B)2
1-296
Corner Detection
Surrounding
pixel j
Pixel under
consideration
Angle
1-297
Corner Detection
⎛ ⎞
R = max ⎜ ∑ I p − I j − T, ∑ I p − I j − T, ⎟
⎜ ⎟
⎝ j: I j ≥ I p + T j: I j ≤ I p − T ⎠
1-298
Corner Detection
1-299
Corner Detection
1-300
Corner Detection
Dialog The Corner Detection dialog box appears as shown in the following
Box figure.
1-301
Corner Detection
1-302
Corner Detection
Method
Specify the method to use to find the corner values. Your
choices are Harris corner detection (Harris & Stephens),
Minimum eigenvalue (Shi & Tomasi), and Local intensity
comparison (Rosten & Drummond).
Sensitivity factor (0<k<0.25)
Specify the sensitivity factor, k. The smaller the value of k
the more likely the algorithm is to detect sharp corners. This
parameter is visible if you set the Method parameter to Harris
corner detection (Harris & Stephens). This parameter is
tunable.
Coefficients for separable smoothing filter
Specify a vector of filter coefficients for the smoothing filter.
This parameter is visible if you set the Method parameter to
Harris corner detection (Harris & Stephens) or Minimum
eigenvalue (Shi & Tomasi).
Intensity comparison threshold
Specify the threshold value used to find valid surrounding pixels.
This parameter is visible if you set the Method parameter to
Local intensity comparison (Rosten & Drummond). This
parameter is tunable.
Maximum angle to be considered a corner (in degrees)
Specify the maximum corner angle. This parameter is visible if
you set the Method parameter to Local intensity comparison
(Rosten & Drummond). This parameter is tunable for Simulation
only.
Output
Specify the block output. Your choices are Corner location,
Corner location and metric matrix, and Metric matrix.
The block outputs the corner locations in an M-by-2 matrix of [x
y] coordinates, where M represents the number of corners. The
block outputs the corner metric value in a matrix, the same size
as the input image.
1-303
Corner Detection
The block repeats this process until it finds all the corners in
the image or it finds the number of corners you specified in the
Maximum number of corners parameter.
1-304
Corner Detection
The Data Types pane of the Corner Detection dialog box appears as
shown in the following figure.
1-305
Corner Detection
1-306
Corner Detection
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
Coefficients
Choose how to specify the word length and the fraction length
of the coefficients:
• When you select Same word length as input, the word length
of the coefficients match that of the input to the block. In this
mode, the fraction length of the coefficients is automatically
set to the binary-point only scaling that provides you with the
best precision possible given the value and word length of the
coefficients.
• When you select Specify word length, you can enter the word
length of the coefficients, in bits. The block automatically sets
the fraction length to give you the best precision.
• When you select Binary point scaling, you can enter the
word length and the fraction length of the coefficients, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the coefficients. The bias
of all signals in the Computer Vision System Toolbox software
is 0.
Product output
As shown in the following figure, the output of the multiplier is
placed into the product output data type and scaling.
1-307
Corner Detection
ADDER
CAST
Input to adder - Accumulator Accumulator
input data type data type data type
1-308
Corner Detection
• 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
is 0.
Memory
Choose how to specify the memory word length and fraction
length:
• When you select Same as 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. This block
requires power-of-two slope and a bias of 0.
Metric output
Choose how to specify the metric output word length and fraction
length:
• When you select Same as accumulator, these characteristics
match those of the accumulator.
• When you select Same as 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. This block
requires power-of-two slope and a bias of 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.
1-309
Corner Detection
See Also Find Local Maxima Computer Vision System Toolbox software
Estimate Geometric Computer Vision System Toolbox software
Transformation
1-310
Corner Detection (To Be Removed)
Description
1-311
Deinterlacing
Description The Deinterlacing block takes the input signal, which is the combination
of the top and bottom fields of the interlaced video, and converts it into
deinterlaced video using line repetition, linear interpolation, or vertical
temporal median filtering.
Note This block supports intensity and color images on its ports.
Complex
Port Input/Output Supported Data Types Values
Supported
Input Combination of top and • Double-precision floating point No
bottom fields of interlaced
• Single-precision floating point
video
• Fixed point
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned
integer
Output Frames of deinterlaced Same as Input port No
video
1-312
Deinterlacing
Line Repetition
Row 1 A B C Row 1
Row 2 Row 2 D E F
Row 3 G H I Row 3
Row 4 Row 4 J K L
Row 5 M N O Row 5
Row 6 Row 6 P Q R
Row 1 A B C Row 1 A B C
Row 2 D E F Row 2 A B C
Row 3 G H I Row 3 G H I
Row 4 J K L Row 4 G H I
Row 5 M N O Row 5 M N O
Row 6 P Q R Row 6 M N O
The following figure illustrates the block’s behavior if you select Linear
interpolation.
1-313
Deinterlacing
Linear Interpolation
Row 1 A B C Row 1
Row 2 Row 2 D E F
Row 3 G H I Row 3
Row 4 Row 4 J K L
Row 5 M N O Row 5
Row 6 Row 6 P Q R
Row 1 A B C Row 1 A B C
Row 3 G H I Row 3 G H I
Row 5 M N O Row 5 M N O
Row 6 P Q R Row 6 M N O
1-314
Deinterlacing
Row 1 A B C Row 1
Row 2 Row 2 D E F
Row 3 G H I Row 3
Row 4 Row 4 J K L
Row 5 M N O Row 5
Row 6 Row 6 P Q R
Row 1 A B C Row 1 A B C
Row 3 G H I Row 3 G H I
Row 5 M N O Row 5 M N O
Row 6 P Q R Row 6 M N O
1-315
Deinterlacing
When you use the row-major functionality, you must consider the
following issues:
• When you select this check box, the first two signal dimensions of the
Deinterlacing block’s input are swapped.
• All the Computer Vision System Toolbox blocks can be used to
process data that is in the row-major format, but you need to know
the image dimensions when you develop your algorithms.
For example, if you use the 2-D FIR Filter block, you need to verify
that your filter coefficients are transposed. If you are using the
Rotate block, you need to use negative rotation angles, etc.
• Only three blocks have the Input image is transposed (data
order is row major) check box. They are the Chroma Resampling,
Deinterlacing, and Insert Text blocks. You need to select this check
box to enable row-major functionality in these blocks. All other blocks
must be properly configured to process data in row-major format.
1-316
Deinterlacing
Step 1:
Create block diagram Algorithm
blocks
Step 2:
Replace source, transpose, and
Embedded sink blocks with target source Embedded
target source and sink blocks that produce target sink
block data in row-major format block
See the DM642 EVM Video ADC and DM642 EVM Video DAC reference
pages.
Example
The following example shows you how to use the Deinterlacing block to
remove motion artifacts from an image.
ex_deinterlace
1-317
Deinterlacing
The original image that contains the motion artifacts appears in the
Input Image window.
1-318
Deinterlacing
1-319
Deinterlacing
1-320
Deinterlacing
Accumulator Accumulator
data type data type Output
data type
Input data type RIGHT SHIFT CAST
ADDER
CAST
Accumulator
data type
You can set the product output, accumulator, and output data types in
the block mask as discussed in the next section.
Dialog The Main pane of the Deinterlacing dialog box appears as shown in
Box the following figure.
Deinterlacing method
Specify how the block deinterlaces the video. Your choices
are Line repetition, Linear interpolation, or Vertical
temporal median filtering.
Input image is transposed (data order is row major)
When you select this check box, the block assumes that the input
buffer contains data elements from the first row first, then data
1-321
Deinterlacing
elements from the second row second, and so on through the last
row.
The Data Types pane of the Deinterlacing dialog box appears as shown
in the following figure.
Note The parameters on the Data Types pane are only available if,
for the Deinterlacing method, you select Linear interpolation.
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
1-322
Deinterlacing
Accumulator
ADDER
CAST
Input to adder - Accumulator Accumulator
input data type data type data type
1-323
Deinterlacing
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the output. This block
requires power-of-two slope and a bias of 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.
1-324
Demosaic
Library Conversions
visionconversions
Description
B G B G
G R G R
B G B G
G R G R
The Demosaic block takes in images in Bayer’s format and outputs RGB
images. The block performs this operation using a gradient-corrected
linear interpolation algorithm or a bilinear interpolation algorithm.
1-325
Demosaic
Complex
Port Input/Output Supported Data Types Values
Supported
I Matrix of intensity values • Double-precision floating point No
• Single-precision floating point
• If, for the Interpolation
algorithm parameter, • Fixed point
you select Bilinear,
• 8-, 16-, and 32-bit signed integer
the number of rows and
columns must be greater • 8-, 16-, and 32-bit unsigned
than or equal to 3. integer
• If, for the Interpolation
algorithm
parameter, you select
Gradient-corrected
linear, the number of
rows and columns must
be greater than or equal
to 5.
R, G, B Matrix that represents one Same as I port No
plane of the input RGB
video stream. Outputs from
the R, G, or B ports have
the same data type.
Image M-by-N matrix of intensity Same as I port No
values or an M-by-N-by-P
color video signal where P is
the number of color planes.
1-326
Demosaic
Input
data type Output
data type
MULTIPLIER CAST ADDER CAST
Accumulator or Accumulator
Input Product output Accumulator data type
data type data type data type
You can set the product output and accumulator data types in the block
mask as discussed in the next section.
1-327
Demosaic
Dialog The Main pane of the Demosaic dialog box appears as shown in the
Box following figure.
Interpolation algorithm
Specify the algorithm the block uses to calculate the missing color
information. Your choices are Bilinear or Gradient-corrected
linear.
Sensor alignment
Select the sequence of R, G and B pixels that correspond to the
2-by-2 block of pixels in the top left corner of the image. You
specify the sequence in left-to-right, top-to-bottom order.
Output image signal
Specify how to output a color video signal. If you select One
multidimensional signal, the block outputs an M-by-N-by-P
color video signal, where P is the number of color planes, at one
port. If you select Separate color signals, additional ports
1-328
Demosaic
The Data Types pane of the Demosaic dialog box appears as shown in
the following figure.
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
1-329
Demosaic
Product output
Accumulator
data type
MULTIPLIER
sfix8_En7 Product output
data type
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:
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 blocks is 0.
Accumulator
ADDER
CAST
Input to adder - Accumulator Accumulator
input data type data type data type
1-330
Demosaic
References [1] Malvar, Henrique S., Li-wei He, and Ross Cutler, “High-Quality
Linear Interpolation for Demosaicing of Bayer-Patterned Color Images,”
Microsoft Research, One Microsoft Way, Redmond, WA 98052
1-331
Dilation
Description The Dilation block rotates the neighborhood or structuring element 180
degrees. Then it slides the neighborhood or structuring element over
an image, finds the local maxima, and creates the output matrix from
these maximum values. If the neighborhood or structuring element has
a center element, the block places the maxima there, as illustrated in
the following figure.
1-332
Dilation
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of intensity • Double-precision floating point No
values
• Single-precision floating point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned
integer
Nhood Matrix or vector of ones and Boolean No
zeros that represents the
neighborhood values
Output Vector or matrix of intensity Same as I port No
values that represents the
dilated image
The output signal has the same data type as the input to the I port.
Use the Neighborhood or structuring element source parameter to
specify how to enter your neighborhood or structuring element values.
If you select Specify via dialog, the Neighborhood or structuring
element parameter appears in the dialog box. If you select Input
port, the Nhood port appears on the block. Use this port to enter your
neighborhood values as a matrix or vector of 1s and 0s. You can only
specify a structuring element using the dialog box.
Use the Neighborhood or structuring element parameter to define
the neighborhood or structuring element that the block applies to the
image. Specify a neighborhood by entering a matrix or vector of 1s and
0s. Specify a structuring element with the strel function from the
Image Processing Toolbox. If the structuring element is decomposable
into smaller elements, the block executes at higher speeds due to the
1-333
Dilation
Dialog The Dilation dialog box appears as shown in the following figure.
Box
1-334
Dilation
References [1] Soille, Pierre. Morphological Image Analysis. 2nd ed. New York:
Springer, 2003.
1-335
Draw Markers
Description The Draw Markers block can draw multiple circles, x-marks, plus signs,
stars, or squares on images by overwriting pixel values. Overwriting
the pixel values embeds the shapes.
This block uses Bresenham’s circle drawing algorithm to draw circles
and Bresenham’s line drawing algorithm to draw all other markers.
Port Description
Complex
Port Input/Output Supported Data Types Values
Supported
Image M-by-N matrix of intensity values • Double-precision floating No
or an M-by-N-by-P color values point
where P is the number of color
• Single-precision floating
planes
point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed
integer
• 8-, 16-, and 32-bit unsigned
integer
R, G, B Scalar, vector, or matrix that Same as Image port No
represents one plane of the input
RGB video stream. Inputs to the
R, G, and B ports must have the
same dimensions and data type.
1-336
Draw Markers
Complex
Port Input/Output Supported Data Types Values
Supported
Pts M-by-2 matrix of [x y] coordinates, • Double-precision floating No
point
x1 y1 • Single-precision floating
x y2
2 point
• 8-, 16-, and 32-bit signed
xM yM integer
where M is the total number • 8-, 16-, and 32-bit unsigned
of markers and each [x y] pair integer
defines the center of a marker.
If the input to the Image port
is an integer, fixed point, or
boolean data type, the input to
the Pts port must also be an
integer data type.
ROI Four-element vector of integers • Double-precision floating No
[x y width height] that define point
a rectangular area in which to
• Single-precision floating
draw the markers. The first two
point
elements represent the one-based
[x y] coordinates of the upper-left • 8-, 16-, and 32-bit signed
corner of the area. The second two integer
elements represent the width and
• 8-, 16-, and 32-bit unsigned
height of the area.
integer
Clr P-element vector or M-by-P matrix Same as Image port No
where P is the number of color
planes.
Output Scalar, vector, or matrix of pixel Same as Image port No
values that contain the marker(s)
1-337
Draw Markers
The output signal is the same size and data type as the inputs to the
Image, R, G, and B ports.
Dialog The Draw Markers dialog box appears as shown in the following figure.
Box
1-338
Draw Markers
Marker shape
Specify the type of marker(s) to draw. Your choices are Circle,
X-mark, Plus, Star, or Square.
1-339
Draw Markers
When you select Circle, X-mark, or Star, and you select the
Use antialiasing check box, the block performs a smoothing
algorithm. The algorithm is similar to the poly2mask function to
determine which subpixels to draw.
Marker size
Enter a scalar value that represents the size of the marker, in
pixels.
When you select the Filled check box, the Fill color source,
Fill color and Opacity factor (between 0 and 1) parameters
appear in the dialog box.
Fill color source
Specify source for fill color value. You can select Specify via
dialog or Input port. This parameter appears when you select
the Filled check box. When you select Input port, the color
input port clr appears on the block.
Fill color
If you select Black, the marker is black. If you select White, the
marker is white. If you select User-specified value, the Color
value(s) parameter appears in the dialog box. This parameter is
visible if you select the Filled check box.
Border color source
Specify source for the border color value to either Specify via
dialog or Input port. Border color options are visible when the
fill shapes options are not selected. This parameter is visible if
1-340
Draw Markers
you select the Filled check box. When you select Input port, the
color input port clr appears on the block.
Border color
Specify the appearance of the shape’s border. If you select Black,
the border is black. If you select White, the border is white. If you
select User-specified value, the Color value(s) parameter
appears in the dialog box. This parameter is visible if you clear
the Fill shapes check box.
Color value(s)
Specify an intensity or color value for the marker’s border or fill.
This parameter appears when you set the Border color or Fill
color parameters, to User-specified value. Tunable.
The following table describes what to enter for the color value
based on the block input and the number of shapes you are
drawing.
1-341
Draw Markers
Draw markers in
Specify the area in which to draw the markers. When you select
Entire image, you can draw markers in the entire image. When
you select Specify region of interest via port, the ROI
port appears on the block. Enter a four-element vector, [x y
width height], where [x y] are the coordinates of the upper-left
corner of the area.
Use antialiasing
Perform a smoothing algorithm on the marker. This parameter is
visible if, for the Marker shape parameter, you select Circle,
X-mark, or Star.
Image signal
Specify how to input and output a color video signal. When you
select One multidimensional signal, the block accepts an
M-by-N-by-P color video signal, where P is the number of color
planes, at one port. When you select Separate color signals,
additional ports appear on the block. Each port accepts one
M-by-N plane of an RGB video stream.
1-342
Draw Markers
1-343
Draw Markers (To Be Removed)
Description
Note This Draw Markers block will be removed in a future release. It
uses the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated Draw Markers block that
uses the one-based, [x y] coordinate system.
1-344
Draw Shapes
Description The Draw Shapes block draws multiple rectangles, lines, polygons, or
circles on images by overwriting pixel values. As a result, the shapes
are embedded on the output image.
This block uses Bresenham’s line drawing algorithm to draw lines,
polygons, and rectangles. It uses Bresenham’s circle drawing algorithm
to draw circles.
The output signal is the same size and data type as the inputs to the
Image, R, G, and B ports.
You can set the shape fill or border color via the input port or via the
input dialog. Use the color input or color parameter to determine the
appearance of the rectangle(s), line(s), polygon(s), or circle(s).
Port Description
Complex
Supported Data
Port Input/Output Values
Types
Supported
1-345
Draw Shapes
Complex
Supported Data
Port Input/Output Values
Types
Supported
1-346
Draw Shapes
Complex
Supported Data
Port Input/Output Values
Types
Supported
1-347
Draw Shapes
Drawing Rectangles
The Draw Shapes block lets you draw one or more rectangles. Set the
Shape parameter to Rectangles, and then follow the instructions
in the table to specify the input to the Pts port to obtain the desired
number of rectangles.
1-348
Draw Shapes
x1 y1 width1 height1
x y2 width2 height2
2
xM yM widthM heightM
where each row of the matrix
corresponds to a different rectangle
and is of the same form as the vector
for a single rectangle.
1-349
Draw Shapes
1-350
Draw Shapes
1-351
Draw Shapes
If you select the Use antialiasing check box, the block applies an edge
smoothing algorithm.
For examples of how to use the Draw Shapes block to draw a line, see
“Detect Lines in Images” and “Measure Angle Between Lines”.
Drawing Polygons
The Draw Shapes block lets you draw one or more polygons. Set the
Shape parameter to Polygons, and then follow the instructions in the
table to specify the input to the Pts port to obtain the desired number
of polygons.
1-352
Draw Shapes
1-353
Draw Shapes
Drawing Circles
The Draw Shapes block lets you draw one or more circles. Set the Shape
parameter to Circles, and then follow the instructions in the table to
specify the input to the Pts port to obtain the desired number of circles.
1-354
Draw Shapes
x1 y1 radius1
x y2 radius2
2
xM yM radiusM
where each row of the matrix
corresponds to a different circle and
is of the same form as the vector for a
single circle.
1-355
Draw Shapes
Dialog
Box
1-356
Draw Shapes
Shape
Specify the type of shape(s) to draw. Your choices are Rectangles,
Lines, Polygons, or Circles.
When you select this check box, the Fill color source, Fill color
and Opacity factor (between 0 and 1) parameters appear in
the dialog box.
Note If you are generating code and you select the Fill shapes
check box, the word length of the block input(s) cannot exceed
16 bits.
When you do not select the Fill shapes check box, the Border
color source, and Border color parameters are available.
Fill color source
Specify source for fill color value to either Specify via dialog
or Input port. This parameter appears when you select the Fill
shapes check box. When you select Input port, the color input
port clr appears on the block.
Fill color
Specify the fill color for shape. You can specify either Black, White,
or User-specified value. When you select User-specified
value, the Color value(s) parameter appears in the dialog box.
This parameter is visible if you select the Fill shapes check box.
1-357
Draw Shapes
The following table describes what to enter for the color value
based on the block input and the number of shapes you are
drawing.
1-358
Draw Shapes
Draw shapes in
Specify the type of area in which to draw shapes. You can define
one of the following:
• Entire image, enables you to draw shapes in the entire image.
• Specify region of interest via port. When you select
this option, the ROI port appears on the block. Enter a
four-element vector of integer values, [x y width height],
where [x y] are the coordinates of the upper-left corner of the
area.
Note If you specify values that are outside the image, the
block sets the values to the image boundaries.
1-359
Draw Shapes
Use antialiasing
Perform a smoothing algorithm on the line, polygon, or circle.
This parameter is visible if, for the Shape parameter, you select
Lines, Polygons, or Circles.
Image signal
Specify how to input and output a color video signal. Select one of
the following:
• One multidimensional signal, the block accepts an
M-by-N-by-P color video signal, where P is the number of color
planes, at one port.
• Separate color signals, additional ports appear on the
block. Each port accepts one M-by-N plane of an RGB video
stream.
1-360
Draw Shapes (To Be Removed)
Description
Note This Draw Shapes block will be removed in a future release. It
uses the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated Draw Shapes block that
uses the one-based, [x y] coordinate system.
1-361
Edge Detection
Purpose Find edges of objects in images using Sobel, Prewitt, Roberts, or Canny
method
Description If, for the Method parameter, you select Sobel, Prewitt, or Roberts,
the Edge Detection block finds the edges in an input image by
approximating the gradient magnitude of the image. The block
convolves the input matrix with the Sobel, Prewitt, or Roberts kernel.
The block outputs two gradient components of the image, which are
the result of this convolution operation. Alternatively, the block can
perform a thresholding operation on the gradient magnitudes and
output a binary image, which is a matrix of Boolean values. If a pixel
value is 1, it is an edge.
If, for the Method parameter, you select Canny, the Edge Detection
block finds edges by looking for the local maxima of the gradient of
the input image. It calculates the gradient using the derivative of the
Gaussian filter. The Canny method uses two thresholds to detect strong
and weak edges. It includes the weak edges in the output only if they
are connected to strong edges. As a result, the method is more robust to
noise, and more likely to detect true weak edges.
Complex
Port Input/Output Supported Data Types Values
Supported
I Matrix of intensity • Double-precision floating point No
values
• Single-precision floating point
• Fixed point (not supported for the
Canny method)
• 8-, 16-, 32-bit signed integer (not
supported for the Canny method)
1-362
Edge Detection
Complex
Port Input/Output Supported Data Types Values
Supported
The output of the Gv, Gh, G45, and G135 ports is the same data type
as the input to the I port. The input to the Th port must be the same
data type as the input to the I port.
Use the Method parameter to specify which algorithm to use to find
edges. You can select Sobel, Prewitt, Roberts, or Canny to find edges
using the Sobel, Prewitt, Roberts, or Canny method.
Sobel, Prewitt, and Roberts Methods
Use the Output type parameter to select the format of the output. If
you select Binary image, the block outputs a Boolean matrix at the
Edge port. The nonzero elements of this matrix correspond to the edge
pixels and the zero elements correspond to the background pixels. If
you select Gradient components and, for the Method parameter, you
1-363
Edge Detection
1-364
Edge Detection
Canny Method
Select the User-defined threshold check box to define the low and
high threshold values. If you clear this check box, the block computes
the threshold values for you.
Use the Threshold source parameter to specify how to enter your
threshold values. If you select Specify via dialog, the Threshold
[low high] parameter appears in the dialog box. Enter the threshold
values. If a pixel’s magnitude in the gradient image, which is formed
by convolving the input image with the derivative of the Gaussian
filter, exceeds the high threshold, then the pixel corresponds to a strong
edge. Any pixel connected to a strong edge and having a magnitude
greater than the low threshold corresponds to a weak edge. If, for the
Threshold source parameter, you choose Input port, use input port
Th to specify a two-element vector of threshold values. These values
must have the same data type as the input data.
The Edge Detection block computes the automatic threshold values
using an approximation of the number of weak and nonedge image
pixels. Enter this approximation for the Approximate percentage of
weak edge and nonedge pixels (used to automatically calculate
threshold values) parameter.
Use the Standard deviation of Gaussian filter parameter to define
the Gaussian filter whose derivative is convolved with the input image.
1-365
Edge Detection
The block squares the threshold and compares it to the sum of the
squared gradients to avoid using square roots.
Threshold:
MULTIPLIER CAST
Product output Accumulator
Input data type
data type data type
Gradients:
MULTIPLIER CAST
Product output Accumulator
Accumulator data type
data type data type
ADDER
Accumulator
data type
MULTIPLIER CAST
Product output Accumulator
Accumulator data type data type
data type
1-366
Edge Detection
You can set the product output and accumulator data types in the block
mask as discussed in the next section.
Dialog The Main pane of the Edge Detection dialog box appears as shown in
Box the following figure.
Method
Select the method by which to perform edge detection. Your
choices are Sobel, Prewitt, Roberts, or Canny.
Output type
Select the desired form of the output. If you select Binary
image, the block outputs a matrix that is filled with ones,
which correspond to edges, and zeros, which correspond to the
background. If you select Gradient components and, for the
Method parameter, you select Sobel or Prewitt, the block
outputs the gradient components that correspond to the horizontal
1-367
Edge Detection
1-368
Edge Detection
The Data Types pane of the Edge Detection dialog box appears
as shown in the following figure.
1-369
Edge Detection
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
1-370
Edge Detection
Product output
I data type
MULTIPLIER
Product output
Internal coefficients data type
data type
MULTIPLIER
Product output
Accumulator data type
data type
Here, the internal coefficients are the Sobel, Prewitt, or Roberts
masks. 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.
• When you select Same as first input, these characteristics
match those of the first 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
blocks is 0.
1-371
Edge Detection
Accumulator
1-372
Edge Detection
[2] Pratt, William K. Digital Image Processing, 2nd ed. New York: John
Wiley & Sons, 1991.
1-373
Erosion
Description The Erosion block slides the neighborhood or structuring element over
an image, finds the local minima, and creates the output matrix from
these minimum values. If the neighborhood or structuring element has
a center element, the block places the minima there, as illustrated in
the following figure.
1-374
Erosion
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of intensity • Double-precision floating point No
values
• Single-precision floating point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned
integer
Nhood Matrix or vector of 1s and Boolean No
0s that represents the
neighborhood values
Output Vector or matrix of intensity Same as I port No
values that represents the
eroded image
The output signal is the same data type as the input to the I port.
Use the Neighborhood or structuring element source parameter to
specify how to enter your neighborhood or structuring element values.
If you select Specify via dialog, the Neighborhood or structuring
element parameter appears in the dialog box. If you select Input
port, the Nhood port appears on the block. Use this port to enter your
neighborhood values as a matrix or vector of 1s and 0s. You can only
specify a structuring element using the dialog box.
Use the Neighborhood or structuring element parameter to define
the neighborhood or structuring element that the block applies to the
image. Specify a neighborhood by entering a matrix or vector of 1s and
0s. Specify a structuring element with the strel function from the
Image Processing Toolbox. If the structuring element is decomposable
into smaller elements, the block executes at higher speeds due to the
1-375
Erosion
Dialog The Erosion dialog box appears as shown in the following figure.
Box
1-376
Erosion
References [1] Soille, Pierre. Morphological Image Analysis. 2nd ed. New York:
Springer, 2003.
1-377
Estimate Geometric Transformation
Description
Complex
Port Input/Output Supported Data Types Values
Supported
Pts1/Pts2 M-by-2 Matrix of • Double No
one-based [x y]
• Single
point coordinates,
where M represents • 8, 16, 32-bit signed integer
the number of
• 8, 16, 32-bit unsigned integer
points.
Num Scalar value that • 8, 16, 32-bit signed integer No
represents the
• 8, 16, 32-bit unsigned integer
number of valid
points in Pts1 and
Pts 2.
1-378
Estimate Geometric Transformation
Complex
Port Input/Output Supported Data Types Values
Supported
TForm 3-by-2 or 3-by-3 • Double No
transformation
• Single
matrix.
Inlier M-by-1 vector Boolean No
indicating which
points have been
used to calculate
TForm.
Ports Pts1 and Pts2 are the points on two images that have the same
data type. The block outputs the same data type for the transformation
matrix
When Pts1 and Pts2 are single or double, the output transformation
matrix will also have single or double data type. When Pts1 and
Pts2 images are built-in integers, the option is available to set the
transformation matrix data type to either Single or Double. The TForm
output provides the transformation matrix. The Inlier output port
provides the Inlier points on which the transformation matrix is based.
This output appears when you select the Output Boolean signal
indicating which point pairs are inliers checkbox.
points, pia (image a, Pts1) and pib (image b, Pts 2) is an inlier only
when the distance between pib and the projection of pia based on the
transformation matrix falls within the specified threshold. The distance
metric used in the RANSAC algorithm is as follows:
Num
d= ∑ min( D( pib , ψ( pia : H )), t)
i=1
1-379
Estimate Geometric Transformation
The Least Median Squares algorithm assumes at least 50% of the point
pairs can be mapped by a transformation matrix. The algorithm does
not need to explicitly specify the distance threshold. Instead, it uses the
median distance between all input point pairs. The distance metric
used in the Least Median of Squares algorithm is as follows:
Transformations
The Estimate Geometric Transformation block supports
Nonreflective similarity, affine, and projective transformation
types, which are described in this section.
Nonreflective similarity transformation supports translation,
rotation, and isotropic scaling. It has four degrees of freedom and
requires two pairs of points.
1-380
Estimate Geometric Transformation
h1 h2
H h2 h1
The transformation matrix is: h3 h4
h1 h4
The transformation matrix is: H h2 h5
h3 h6
The projection of a point x y by H is: xˆ yˆ x y 1 H
Projective transformation supports tilting in addition to all
transformations that the affine transformation supports.
h1 h4 h7
The transformation matrix is : h h2 h5 h8
h3 h6 h9
1-381
Estimate Geometric Transformation
Distance Measurement
For computational simplicity and efficiency, this block uses algebraic
T
distance. The algebraic distance for a pair of points, ⎡ x a ya ⎤ on
⎣ ⎦
image a, and xb yb on image b , according to transformation H, is
defined as follows;
For projective transformation:
1
D( pib , ψ( pia : H )) = ((ua − wa xb )2 + (va − wa yb )2 ) 2 , where
uˆ a vˆ a w
ˆ a x a y a 1 H
For Nonreflective similarity or affine transformation:
1
D( pib , ψ( pia : H )) = (( x a − xb )2 + ( y a − yb )2 ) 2
,
where xˆ a yˆ a x a y a 1 H
Algorithm
The block performs a comparison and repeats it K number of times
between successive transformation matrices. If you select the Find
and exclude outliers option, the RANSAC and Least Median Squares
(LMS) algorithms become available. These algorithms calculate and
compare a distance metric. The transformation matrix that produces
the smaller distance metric becomes the new transformation matrix
that the next comparison uses. A final transformation matrix is
resolved when either:
1-382
Estimate Geometric Transformation
1-383
Estimate Geometric Transformation
log(1 p)
K
log(1 qs )
where
1-384
Estimate Geometric Transformation
1-385
Estimate Geometric Transformation
Dialog Box
1-386
Estimate Geometric Transformation
Transformation Type
Specify transformation type, either Nonreflective similarity,
affine, or projective transformation. If you select projective
transformation, you can also specify a scalar algebraic distance
threshold for determining inliers. If you select either affine
or projective transformation, you can specify the distance
threshold for determining inliers in pixels. See “Transformations”
on page 1-380 for a more detailed discussion. The default value
is projective.
Find and exclude outliers
When selected, the block finds and excludes outliers from the
input points and uses only the inlier points to calculate the
transformation matrix. When this option is not selected, all input
points are used to calculate the transformation matrix.
Method
Select either the RANdom SAmple Consensus (RANSAC) or the
Least Median of Squares algorithm to find outliers. See
“RANSAC and Least Median Squares Algorithms” on page 1-379
for a more detailed discussion. This parameter appears when you
select the Find and exclude outliers check box.
Algebraic distance threshold for determining inliers
Specify a scalar threshold value for determining inliers. The
threshold controls the upper limit used to find the algebraic
distance in the RANSAC algorithm. This parameter appears
when you set the Method parameter to Random Sample
Consensus (RANSAC) and the Transformation type parameter
to projective. The default value is 1.5.
Distance threshold for determining inliers (in pixels)
Specify the upper limit distance a point can differ from the
projection location of its associating point. This parameter
appears when you set the Method parameter to Random
Sample Consensus (RANSAC) and you set the value of the
Transformation type parameter to Nonreflective similarity
or affine. The default value is 1.5.
1-387
Estimate Geometric Transformation
1-388
Estimate Geometric Transformation
1-389
Estimate Geometric Transformation
1-390
Estimate Geometric Transformation
Video Mosaicking
To see an example of the Estimate Geometric Transformation block
used in a model with other blocks, see the “Video Mosaicking” example.
1-391
Estimate Geometric Transformation
1-392
Estimate Geometric Transformation (To Be Removed)
Description
1-393
Find Local Maxima
Library Statistics
visionstatistics
Description The Find Local Maxima block finds the local maxima within an input
matrix. It does so by comparing the maximum value in the matrix to
a user-specified threshold. The block considers a value to be a valid
local maximum when the maximum value is greater than or equal to
the specified threshold. The determination of the local maxima is based
on the neighborhood, an area around and including the maximum
value. After finding the local maxima, the block sets all the matrix
values in the neighborhood, including the maximum value, to 0. This
step ensures that subsequent searches do not include this maximum.
The size of the neighborhood must be appropriate for the data set.
That is, the threshold must eliminate enough of the values around the
maximum so that false peaks are not discovered. The process repeats
until the block either finds all valid maximas or the number of local
maximas equal the Maximum number of local maxima value. The
block outputs one-based [x y] coordinates of the maxima. The data to all
input ports must be the same data type.
If the input to this block is a Hough matrix output from the Hough
Transform block, select the Input is Hough matrix spanning full
theta range check box. If you select this check box, the block assumes
that the Hough port input is antisymmetric about the rho axis and
theta ranges from -pi/2 to pi/2 radians. If the block finds a local maxima
near the boundary, and the neighborhood lies outside the Hough
matrix, then the block detects only one local maximum. It ignores the
corresponding antisymmetric maximum.
1-394
Find Local Maxima
Dialog The Find Local Maxima dialog box appears as shown in the following
Box figure.
1-395
Find Local Maxima
1-396
Find Local Maxima
applies when you clear the Output variable size signal check
box.
Examples See “Detect Lines in Images” and “Measure Angle Between Lines” in
the Computer Vision System Toolbox User’s Guide.
Supported The block outputs the one-based [x y] coordinates of the maxima at the
Data Idx port and the number of valid local maxima found at the Count port.
Types
Complex
Port Input/Output Supported Data Types Values
Supported
I/Hough Matrix in which you • Double-precision floating point No
want to find the maxima.
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Th Scalar value that Same as I/Hough port No
represents the value
the maxima should meet
or exceed.
Idx An M-by-2 matrix No
of one-based [x y] • Double-precision floating point
coordinates, where M
• Single-precision floating point
represents the number
of local maximas found. • 8-, 16-, and 32-bit unsigned integer
Count Scalar value that Same as Idx port No
represents the number
of maxima that meet
or exceed the threshold
value.
1-397
Find Local Maxima
1-398
Find Local Maxima (To Be Removed)
Library Statistics
Description
Note This Find Local Maxima block will be removed in a future
release. It uses the zero-based, [row column] coordinate system. It is
recommended that you replace this block with the updated Find Local
Maxima block that uses the one-based, [x y] coordinate system.
1-399
Frame Rate Display
Library Sinks
visionsinks
Description The Frame Rate Display block calculates and displays the average
update rate of the input signal. This rate is in relation to the wall clock
time. For example, if the block displays 30, the model is updating the
input signal 30 times every second. You can use this block to check the
video frame rate of your simulation. During code generation, Simulink
Coder does not generate code for this block.
Note This block supports intensity and color images on its port.
Complex
Port Input Supported Data Types Values
Supported
Input M-by-N matrix of intensity • Double-precision floating point No
values or an M-by-N-by-P
• Single-precision floating point
color video signal where
P is the number of color • Fixed point
planes
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
Use the Calculate and display rate every parameter to control how
often the block updates the display. When this parameter is greater
than 1, the block displays the average update rate for the specified
number of video frames. For example, if you enter 10, the block
calculates the amount of time it takes for the model to pass 10 video
frames to the block. It divides this time by 10 and displays this average
video frame rate on the block.
1-400
Frame Rate Display
Note If you do not connect the Frame Rate Display block to a signal
line, the block displays the base (fastest) rate of the Simulink model.
Dialog The Frame Rate Display dialog box appears as shown in the following
Box figure.
1-401
From Multimedia File
Purpose Read video frames and audio samples from compressed multimedia file
Library Sources
visionsources
Description
The From Multimedia File block reads audio samples, video frames, or
both from a multimedia file. The block imports data from the file into a
Simulink model.
Note This block supports code generation for the host computer
that has file I/O available. You cannot use this block with Real-Time
Windows Target™ software because that product does not support file
I/O.
The generated code for this block relies on prebuilt library files. You can
run this code outside the MATLAB environment, or redeploy it, but be
sure to account for these extra library files when doing so. The packNGo
function creates a single zip file containing all of the pieces required to
run or rebuild this code. See packNGo for more information.
To run an executable file that was generated from a model containing
this block, you may need to add precompiled shared library files to
your system path. See “Simulink Coder”, “Simulink Shared Library
Dependencies”, and “Accelerating Simulink Models” for details.
This block allows you to read WMA/WMV streams to disk or across a
network connection. Similarly, the To Multimedia File block allows you
to write WMA/WMV streams to disk or across a network connection. If
you want to play an MP3/MP4 file in Simulink, but you do not have the
1-402
From Multimedia File
codecs, you can re-encode the file as WMA/WMV, which are supported
by the Computer Vision System Toolbox.
Video:
MPEG (.mpeg)
MPEG-2 (.mp2)
MPEG-1.mpg
1-403
From Multimedia File
Note MJ2 files with bit depth higher than 8-bits is not supported by
vision.VideoFileReader. Use VideoReader and VideoWriter for
higher bit depths.
Ports The output ports of the From Multimedia File block change according to
the content of the multimedia file. If the file contains only video frames,
1-404
From Multimedia File
the Image, intensity I, or R,G,B ports appear on the block. If the file
contains only audio samples, the Audio port appears on the block. If
the file contains both audio and video, you can select the data to emit.
The following table describes available ports.
Port Description
Image M-by-N-by-P color video signal where P is the number of color planes.
I M-by-N matrix of intensity values.
R, G, B Matrix that represents one plane of the RGB video stream. Outputs
from the R, G, or B ports must have same dimensions.
Audio Vector of audio data.
Y, Cb, Cr Matrix that represents one frame of the YCbCr video stream. The Y,
Cb, Cr ports produce the following outputs:
Y: M x N
N
Cb: M x 2
N
Cr: M x 2
Sample The sample rate that the block uses depends on the audio and video
Rates sample rate. While the FMMF block operates at a single rate in
Simulink, the underlying audio and video streams can produce different
rates. In some cases, when the block outputs both audio and video,
makes a small adjustment to the video rate.
1-405
From Multimedia File
ceil( AudioSampleRate )
FPS
Sample Sample time = AudioSampleRate .
Time AudioSampleRate
Calculations When audio sample time, FPS is noninteger, the
Used for 1
Video and equation cannot reduce to FPS .
Audio
Files In this case, to prevent synchronization problems, the block drops
the corresponding video frame when the audio stream leads the video
1
stream by more than FPS .
In summary, the block outputs one video frame at each Simulink
time step. To calculate the number of audio samples to output at
each time step, the block divides the audio sample rate by the video
frame rate (fps). If the audio sample rate does not divide evenly by
the number of video frames per second, the block rounds the number
of audio samples up to the nearest whole number. If necessary, the
block periodically drops a video frame to maintain synchronization
for large files.
Dialog The Main pane of the From Multimedia File block dialog appears as
Box follows.
1-406
From Multimedia File
File name
Specify the name of the multimedia file from which to read. The
block determines the type of file (audio and video, audio only, or
video only) and provides the associated parameters.
If the location of the file does not appear on your MATLAB path,
use the Browse button to specify the full path. Otherwise, if the
1-407
From Multimedia File
location of this file appears on your MATLAB path, enter only the
file name. On Windows platforms, this parameter supports URLs
that point to MMS (Microsoft Media Server) streams.
Inherit sample time from file
Select the Inherit sample time from file check box if you want
the block sample time to be the same as the multimedia file. If you
clear this check box, enter the block sample time in the Desired
sample time parameter field. The file that the From Multimedia
File block references, determines the block default sample time.
You can also set the sample time for this block manually. If you
do not know the intended sample rate of the video, let the block
inherit the sample rate from the multimedia file.
Desired sample time
Specify the block sample time. This parameter becomes available
if you clear the Inherit sample time from file check box.
Number of times to play file
Enter a positive integer or inf to represent the number of times
to play the file.
Output end-of-file indicator
Use this check box to determine whether the output is the last
video frame or audio sample in the multimedia file. When you
select this check box, a Boolean output port labeled EOF appears
on the block. The output from the EOF port defaults to 1 when
the last video frame or audio sample is output from the block.
Otherwise, the output from the EOF port defaults to 0.
Multimedia outputs
Specify Video and audio, Video only, or Audio only output file
type. This parameter becomes available only when a video signal
has both audio and video.
Samples per audio channel
Specify number of samples per audio channel. This parameter
becomes available for files containing audio.
1-408
From Multimedia File
The Data Types pane of the To Multimedia File block dialog box
appears as follows.
1-409
From Multimedia File
1-410
From Multimedia File
Supported For source blocks to display video data properly, double- and
Data single-precision floating-point pixel values must be between 0 and 1.
Types For other data types, the pixel values must be between the minimum
and maximum values supported by their data type.
1-411
From Multimedia File
1-412
Gamma Correction
Library Conversions
visionconversions
Description Use the Gamma Correction block to apply or remove gamma correction
from an image or video stream. For input signals normalized between 0
and 1, the block performs gamma correction as defined by the following
equations. For integers and fixed-point data types, these equations are
generalized by applying scaling and offset values specific to the data
type:
1
SLS =
γ
( 1 γ −1)
− γBP + BP
BP
γSLS
FS = ( 1 γ −1)
BP
1
γ
CO = FS BP − SLS BP
SLS I , I Bp
I 1
F I C , I B
S O p
SLS is the slope of the straight line segment. BP is the break point
of the straight line segment, which corresponds to the Break point
parameter. FS is the slope matching factor, which matches the slope of
the linear segment to the slope of the power function segment. CO is the
segment offset, which ensures that the linear segment and the power
function segments connect. Some of these parameters are illustrated
by the following diagram.
1-413
Gamma Correction
I
, I SLS B p
SLS
I
I CO
F , I SLS B p
S
1-414
Gamma Correction
Break
Standard Slope Point Gamma
CIE L* 9.033 0.008856 3
Recommendation ITU-R BT.709-3, 4.5 0.018
Parameter Values for the HDTV 20
Standards for Production and 9
International Programme
Exchange
sRGB 12.92 0.00304 2.4
Note This block supports intensity and color images on its ports.
The properties of the input and output ports are summarized in the
following table:
Complex
Port Input/Output Supported Data Types Values
Supported
I M-by-N matrix of intensity • Double-precision floating point No
values or an M-by-N-by-P color
• Single-precision floating point
video signal where P is the
number of color planes • Fixed point (up to 16-bit word
length)
• 8- and 16-bit signed integer
• 8- and 16-bit unsigned integer
I’ M-by-N matrix of intensity Same as I port No
values or an M-by-N-by-P color
video signal where P is the
number of color planes
1-415
Gamma Correction
Dialog The Gamma Correction dialog box appears as shown in the following
Box figure.
Operation
Specify the block’s operation. Your choices are Gamma or De-gamma.
1-416
Gamma Correction
Gamma
If, for the Operation parameter, you select Gamma, enter the
desired gamma value of the output video stream. This value must
be greater than or equal to 1. If, for the Operation parameter,
you select De-gamma, enter the gamma value of the input video
stream.
Linear segment
Select this check box if you want the gamma curve to have a
linear portion near the origin.
Break point
Enter a scalar value that indicates the I-axis value of the end of
the linear segment. This parameter is visible if you select the
Linear segment check box.
References [1] Poynton, Charles. Digital Video and HDTV Algorithms and
Interfaces. San Francisco, CA: Morgan Kaufman Publishers, 2003.
1-417
Gaussian Pyramid
Library Transforms
visiontransforms
Note This block supports intensity and color images on its ports.
Complex
Port Output Supported Data Types Values
Supported
Input In Reduce mode, the input • Double-precision floating point No
can be an M-by-N matrix
• Single-precision floating point
of intensity values or an
M-by-N-by-P color video • Fixed point
signal where P is the
• 8-, 16-, 32-bit signed integer
number of color planes.
• 8-, 16-, 32-bit unsigned integer
In Expand mode, the input
can be a scalar, vector, or
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.
Output In Reduce mode, the Same as Input port No
output can be a scalar,
vector, or matrix that
1-418
Gaussian Pyramid
Complex
Port Output Supported Data Types Values
Supported
⎛M⎞ ⎛N⎞
ceil ⎜ ⎟ − by − ceil ⎜ ⎟
⎝ 2 ⎠ ⎝ 2⎠
You must repeat this calculation for each successive pyramid level. If
you have an M-by-N input image and you set the Operation parameter
to Expand, you can calculate the dimensions of the output image using
the following equation:
⎡( M − 1) 2l + 1⎤ − by − ⎡( N − 1) 2l + 1⎤
⎣ ⎦ ⎣ ⎦
In the previous equation, l is the scalar value from 1 to inf that you
enter for the Pyramid level parameter.
1-419
Gaussian Pyramid
Examples
The following example model shows how to construct a Laplacian
pyramid:
ex_laplacian
1-420
Gaussian Pyramid
1-421
Gaussian Pyramid
1-422
Gaussian Pyramid
1-423
Gaussian Pyramid
You can set the coefficients table, product output, accumulator, and
output data types in the block mask.
Dialog The Main pane of the Gaussian Pyramid dialog box appears as shown
Box in the following figure.
1-424
Gaussian Pyramid
Operation
Specify whether you want to reduce or expand the input image.
1-425
Gaussian Pyramid
Pyramid level
Specify the number of times the block upsamples or downsamples
each dimension of the image by a factor of 2.
Coefficient source
Determine how to specify the coefficients of the lowpass filter.
Your choices are Default separable filter [1/4-a/2 1/4 a
1/4 1/4-a/2] or Specify via dialog.
a
Enter a scalar value that defines the coefficients in the default
separable filter [1/4-a/2 1/4 a 1/4 1/4-a/2]. This parameter
is visible if, for the Coefficient source parameter, you select
Default separable filter [1/4-a/2 1/4 a 1/4 1/4-a/2].
Coefficients for separable filter
Enter a vector of separable filter coefficients. This parameter
is visible if, for the Coefficient source parameter, you select
Specify via dialog.
The Data Types pane of the Gaussian Pyramid dialog box appears
as shown in the following figure.
1-426
Gaussian Pyramid
Rounding mode
Select the rounding mode for fixed-point operations.
1-427
Gaussian Pyramid
Overflow mode
Select the overflow mode for fixed-point operations.
Coefficients
Choose how to specify the word length and the fraction length
of the coefficients:
• When you select Same word length as input, the word length
of the coefficients match that of the input to the block. In this
mode, the fraction length of the coefficients is automatically
set to the binary-point only scaling that provides you with the
best precision possible given the value and word length of the
coefficients.
• When you select Specify word length, you can enter the word
length of the coefficients, in bits. The block automatically sets
the fraction length to give you the best precision.
• When you select Binary point scaling, you can enter the
word length and the fraction length of the coefficients, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the coefficients. The bias of
all signals in the Computer Vision System Toolbox blocks is 0.
Product output
1-428
Gaussian Pyramid
• 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
blocks is 0.
Accumulator
1-429
Gaussian Pyramid
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select Same as 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 blocks 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.
1-430
Histogram Equalization
Complex
Port Input/Output Supported Data Types Values
Supported
I Matrix of intensity values • Double-precision floating point No
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Hist Vector of integer values • Double-precision floating point No
that represents the
• Single-precision floating point
desired intensity values in
each bin • 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Output Matrix of intensity values Same as I port No
If the data type of input to the I port is floating point, the input to Hist
port must be the same data type. The output signal has the same data
type as the input signal.
1-431
Histogram Equalization
Note The vector input to the Hist port must be normalized such that
the sum of the values in all the bins is equal to the number of pixels
in the input image. The block does not error if the histogram is not
normalized.
Examples See “Adjust the Contrast of Intensity Images” and“Adjust the Contrast
of Color Images” in the Computer Vision System Toolbox User’s Guide.
1-432
Histogram Equalization
Target histogram
Designate the histogram you want the output image to have.
If you select Uniform, the block transforms the input image so
that the histogram of the output image is approximately flat. If
you select User-defined, you can specify the histogram of your
output image.
Number of bins
Enter the number of equally spaced bins you want the uniform
histogram to have. This parameter is visible if, for the Target
histogram parameter, you select Uniform.
Histogram source
Select how to specify your histogram. Your choices are Specify
via dialog and Input port. This parameter is visible if, for the
Target histogram parameter, you select User-defined.
Histogram
Enter the desired histogram of the output image. This parameter
is visible if, for the Target histogram parameter, you select
User-defined.
1-433
Histogram Equalization
1-434
Hough Lines
Purpose Find Cartesian coordinates of lines described by rho and theta pairs
Library Transforms
visiontransforms
Description
The Hough Lines block finds the points of intersection between the
reference image boundary lines and the line specified by a (rho, theta)
pair. The block outputs one-based [x y] coordinates for the points of
intersection. The boundary lines indicate the left and right vertical
boundaries and the top and bottom horizontal boundaries of the
reference image.
If the line specified by the (rho, theta) pair does not intersect two border
lines in the reference image, the block outputs the values, [(0,0),
(0,0)]. This output intersection value allows the next block in your
model to ignore the points. Generally, the Hough Lines block precedes a
block that draws a point or shape at the intersection.
The following figure shows the input and output coordinates for the
Hough Lines block.
1-435
Hough Lines
Port Description
Complex
Port Input/Output Supported Data Types Values
Supported
Theta Vector of theta values that • Double-precision floating point No
represent input lines
• Single-precision floating point
• Fixed point (signed, word length
less than or equal to 32)
• 8-, 16-, and 32-bit signed integer
Rho Vector of rho values that Same as Theta port No
represent input lines
1-436
Hough Lines
Complex
Port Input/Output Supported Data Types Values
Supported
Ref I Matrix that represents a • Double-precision floating point No
binary or intensity image or
• Single-precision floating point
matrix that represents one
plane of an RGB image • Fixed-point (signed and unsigned)
• Custom data types
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
Pts M-by-4 matrix of intersection • 32-bit signed integer No
values, where M is the
number of input lines
Dialog The Main pane of the Hough Lines dialog box appears as shown in
Box the following figure.
1-437
Hough Lines
1-438
Hough Lines
The Data Types pane of the Hough Lines dialog box appears as shown
in the following figure.
1-439
Hough Lines
Rounding mode
Select the rounding mode for fixed-point operations.
1-440
Hough Lines
Overflow mode
Select the overflow mode for fixed-point operations.
Sine table
Choose how to specify the word length of the values of the sine
table. The fraction length of the sine table values always equals
the word length minus one:
When you select Specify word length, you can enter the word
length of the sine table.
The sine table values do not obey the Rounding mode and
Overflow mode parameters; they saturate and round to Nearest.
Product output
Use this parameter to specify how to designate this product
output word and fraction lengths:
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. All
signals in the Computer Vision System Toolbox blocks have a
bias of 0.
1-441
Hough Lines
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. All
signals in the Computer Vision System Toolbox software have
a bias of 0.
Examples The following figure shows Line 1 intersecting the boundaries of the
reference image at [(x11, y11) (x12, y12)] and Line 2 intersecting the
boundaries at [(x21, y21) (x22, y22)]
1-442
Hough Lines
1-443
Hough Lines (To Be Removed)
Purpose Find Cartesian coordinates of lines described by rho and theta pairs
Library Transforms
Description
1-444
Hough Transform
Library Transforms
visiontransforms
Description Use the Hough Transform block to find lines in an image. The block
outputs the Hough space matrix and, optionally, the rho-axis and
theta-axis vectors. Peak values in the matrix represent potential lines
in the input image. Generally, the Hough Transform block precedes the
Hough Lines block which uses the output of this block to find lines in an
image. You can instead use a custom algorithm to locate peaks in the
Hough space matrix in order to identify potential lines.
Supported
Port Input/Output Supported Data Types Complex
Values
BW Matrix that represents a Boolean No
binary image
Hough Parameter space matrix • Double-precision floating point No
• Single-precision floating point
• Fixed point (unsigned, fraction
length equal to 0)
• 8-, 16-, 32-bit unsigned integer
Theta Vector of theta values • Double-precision floating point No
• Single-precision floating point
• Fixed point (signed)
• 8-, 16-, 32-bit signed integer
Rho Vector of rho values Same as Theta port No
1-445
Hough Transform
Dialog The Main pane of the Hough Transform dialog box appears as shown in
Boxes the following figure.
1-446
Hough Transform
The Data Types pane of the Hough Transform block dialog appears
as shown in the following figure. The Data Types pane will not show
fixed-point parameters when Output data type parameter is set to
double or single.
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
1-447
Hough Transform
Sine table
Choose how to specify the word length of the values of the sine
table:
• When you select Binary point scaling, you can enter the
word length of the sine table values, in bits.
• When you select Slope and bias scaling, you can enter the
word length of the sine table values, in bits.
The sine table values do not obey the Rounding mode and
Overflow mode parameters; they always saturate and round
to Nearest.
Rho
Choose how to specify the word length and the fraction length
of the rho values:
• When you select Binary point scaling, you can enter the
word length and the fraction length of the rho values, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the rho values. All signals
in Computer Vision System Toolbox blocks have a bias of 0.
Product output
. Use this parameter to specify how to designate the product
output word and fraction lengths:
• 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. All
signals in Computer Vision System Toolbox blocks have a bias
of 0.
1-448
Hough Transform
Accumulator
Use this parameter to specify how to designate this accumulator
word and fraction lengths:
• When you select Same as product output, these
characteristics match the characteristics of the product output.
• 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. All
signals in Computer Vision System Toolbox blocks have a bias
of 0.
See “Multiplication Data Types” for illustrations depicting the
use of the accumulator data type in this block.
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.
Hough output
Choose how to specify the word length and fraction length of the
Hough output of the block:
• When you select Binary point scaling, you can enter the
word length of the Hough output, in bits. The fraction length
always has a value of 0.
• When you select Slope and bias scaling, you can enter the
word length, in bits, of the Hough output. The slope always has
a value of 0. All signals in Computer Vision System Toolbox
blocks have a bias of 0.
Theta output
Choose how to specify the word length and fraction length of the
theta output of the block:
1-449
Hough Transform
• When you select Binary point scaling, you can enter the
word length and the fraction length of the theta output, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the theta output. All
signals in Computer Vision System Toolbox blocks have a bias
of 0.
The variable rho indicates the perpendicular distance from the origin
to the line.
The variable theta indicates the angle of inclination of the normal line
− ≤ < +
from the x-axis. The range of theta is 2 2 with a step-size
determined by the Theta resolution (radians) parameter. The SHT
measures the angle of the line clockwise with respect to the positive
x-axis.
The Hough Transform block creates an accumulator matrix. The (rho,
theta) pair represent the location of a cell in the accumulator matrix.
Every valid (logical true) pixel of the input binary image represented
by (R,C) produces a rho value for all theta values. The block quantizes
1-450
Hough Transform
the rho values to the nearest number in the rho vector. The rho vector
depends on the size of the input image and the user-specified rho
resolution. The block increments a counter (initially set to zero) in those
accumulator array cells represented by (rho, theta) pairs found for each
pixel. This process validates the point (R,C) to be on the line defined by
(rho, theta). The block repeats this process for each logical true pixel in
the image. The Hough block outputs the resulting accumulator matrix.
Examples See “Detect Lines in Images” and “Measure Angle Between Lines” in
the Computer Vision System Toolbox User Guide.
1-451
Image Complement
Library Conversions
visionconversions
Complex
Port Input/Output Supported Data Types Values
Supported
Input Vector or matrix of intensity values • Double-precision No
floating point
• Single-precision
floating point
• Boolean
• 8-, 16-, 32-bit signed
integer
• 8-, 16-, 32-bit unsigned
integer
Output Complement of a binary or intensity Same as Input port No
The dimensions, data type, complexity, and frame status of the input
and output signals are the same.
1-452
Image Complement
Dialog The Image Complement dialog box appears as shown in the following
Box figure.
1-453
Image Data Type Conversion
Purpose Convert and scale input image to specified output data type
Library Conversions
visionconversions
Description The Image Data Type Conversion block changes the data type of the
input to the user-specified data type and scales the values to the new
data type’s dynamic range. To convert between data types without
scaling, use the Simulink Data Type Conversion block.
When converting between floating-point data types, the block casts the
input into the output data type and clips values outside the range to
0 or 1. When converting to the Boolean data type, the block maps 0
values to 0 and all other values to one. When converting to or between
all other data types, the block casts the input into the output data type
and scales the data type values into the dynamic range of the output
data type. For double- and single-precision floating-point data types,
the dynamic range is between 0 and 1. For fixed-point data types, the
dynamic range is between the minimum and maximum values that can
be represented by the data type.
Note This block supports intensity and color images on its ports.
Complex
Port Input/Output Supported Data Types Values
Supported
Input M-by-N matrix of intensity • Double-precision floating point No
values or an M-by-N-by-P
• Single-precision floating point
color video signal where P is
the number of color planes • Fixed point (word length less than
or equal to 16)
• Boolean
• 8-, 16-bit signed integer
1-454
Image Data Type Conversion
Complex
Port Input/Output Supported Data Types Values
Supported
The dimensions, complexity, and frame status of the input and output
signals are the same.
Use the Output data type parameter to specify the data type of your
output signal values.
Dialog The Image Data Type Conversion dialog box appears as shown in the
Box following figure.
1-455
Image Data Type Conversion
Signed
Select this check box if you want the output fixed-point data to
be signed. This parameter is visible if, for the Output data type
parameter, you choose Fixed-point.
Word length
Use this parameter to specify the word length of your fixed-point
output. This parameter is visible if, for the Output data type
parameter, you choose Fixed-point.
Fraction length
Use this parameter to specify the fraction length of your
fixed-point output. This parameter is visible if, for the Output
data type parameter, you choose Fixed-point.
1-456
Image From File
Library Sources
visionsources
Description Use the Image From File block to import an image from a supported
image file. For a list of supported file formats, see the imread function
reference page in the MATLAB documentation. If the image is a
M-by-N array, the block outputs a binary or intensity image, where M
and N are the number of rows and columns in the image. If the image is
a M-by-N-by-P array, the block outputs a color image, where M and N
are the number of rows and columns in each color plane, P.
Complex
Port Output Supported Data Types Values
Supported
Image M-by-N matrix of intensity • Double-precision floating point Yes
values or an M-by-N-by-P
• Single-precision floating point
color video signal where P is
the number of color planes • Fixed point
• Boolean
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
R, G, Scalar, vector, or matrix that Same as I port Yes
B represents one plane of the
input RGB video stream.
Outputs from the R, G,
or B ports have the same
dimensions.
For the Computer Vision System Toolbox blocks to display video data
properly, double- and single-precision floating-point pixel values must
be between 0 and 1. If the input pixel values have a different data type
than the one you select using the Output data type parameter, the
1-457
Image From File
block scales the pixel values, adds an offset to the pixel values so that
they are within the dynamic range of their new data type, or both.
Use the File name parameter to specify the name of the graphics file
that contains the image to import into the Simulink modeling and
simulation software. If the file is not on the MATLAB path, use the
Browse button to locate the file. This parameter supports URL paths.
Use the Sample time parameter to set the sample period of the output
signal.
Use the Image signal parameter to specify how the block outputs a
color video signal. If you select One multidimensional signal, the
block outputs an M-by-N-by-P color video signal, where P is the number
of color planes, at one port. If you select Separate color signals,
additional ports appear on the block. Each port outputs one M-by-N
plane of an RGB video stream.
Use the Output port labels parameter to label your output ports. Use
the spacer character, |, as the delimiter. This parameter is visible if
you set the Image signal parameter to Separate color signals.
On the Data Types pane, use the Output data type parameter to
specify the data type of your output signal.
1-458
Image From File
Dialog The Main pane of the Image From File dialog box appears as shown in
Box the following figure.
File name
Specify the name of the graphics file that contains the image to
import into the Simulink environment.
Sample time
Enter the sample period of the output signal.
Image signal
Specify how the block outputs a color video signal. If you select One
multidimensional signal, the block outputs an M-by-N-by-P
color video signal, where P is the number of color planes, at one
port. If you select Separate color signals, additional ports
appear on the block. Each port outputs one M-by-N plane of an
RGB video stream.
1-459
Image From File
The Data Types pane of the Image From File dialog box appears as
shown in the following figure.
1-460
Image From File
Word length
Specify the word length, in bits, of the fixed-point output data
type. This parameter is only visible if, from the Output data
type list, you select Fixed-point.
Set fraction length in output to
Specify the scaling of the fixed-point output by either of the
following two methods:
• Choose Best precision to have the output scaling
automatically set such that the output signal has the best
possible precision.
• Choose User-defined to specify the output scaling in the
Fraction length parameter.
This parameter is only visible if, from the Output data type list,
you select Fixed-point or when you select User-defined.
Fraction length
For fixed-point output data types, specify the number of fractional
bits, or bits to the right of the binary point. This parameter is
only visible when you select Fixed-point or User-defined for
the Output data type parameter and User-defined for the Set
fraction length in output to parameter.
User-defined data type
Specify any built-in or fixed-point data type. You can specify
fixed-point data types using the sfix, ufix, sint, uint, sfrac,
and ufrac functions from the Fixed-Point Designer™ library.
This parameter is only visible when you select User-defined for
the Output data type parameter.
1-461
Image From File
1-462
Image From Workspace
Library Sources
visionsources
Description Use the Image From Workspace block to import an image from the
MATLAB workspace. If the image is a M-by-N workspace array,
the block outputs a binary or intensity image, where M and N are
the number of rows and columns in the image. If the image is a
M-by-N-by-P workspace array, the block outputs a color image, where
M and N are the number of rows and columns in each color plane, P.
Complex
Port Output Supported Data Types Values
Supported
Image M-by-N matrix of intensity • Double-precision floating point No
values or an M-by-N-by-P
• Single-precision floating point
color video signal where P is
the number of color planes • Fixed point
• Boolean
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
R, G, Scalar, vector, or matrix Same as I port No
B that represents one plane
of the RGB video stream.
Outputs from the R, G,
or B ports have the same
dimensions.
For the Computer Vision System Toolbox blocks to display video data
properly, double- and single-precision floating-point pixel values must
be between 0 and 1. If the input pixel values have a different data type
than the one you select using the Output data type parameter, the
1-463
Image From Workspace
block scales the pixel values, adds an offset to the pixel values so that
they are within the dynamic range of their new data type, or both.
Use the Value parameter to specify the MATLAB workspace variable
that contains the image you want to import into Simulink environment.
Use the Sample time parameter to set the sample period of the output
signal.
Use the Image signal parameter to specify how the block outputs a
color video signal. If you select One multidimensional signal, the
block outputs an M-by-N-by-P color video signal, where P is the number
of color planes, at one port. If you select Separate color signals,
additional ports appear on the block. Each port outputs one M-by-N
plane of an RGB video stream.
Use the Output port labels parameter to label your output ports. Use
the spacer character, |, as the delimiter. This parameter is visible if
you set the Image signal parameter to Separate color signals.
On the Data Types pane, use the Output data type parameter to
specify the data type of your output signal.
1-464
Image From Workspace
Dialog The Main pane of the Image From Workspace dialog box appears as
Box shown in the following figure.
Value
Specify the MATLAB workspace variable that you want to import
into Simulink environment.
Sample time
Enter the sample period of the output signal.
Image signal
Specify how the block outputs a color video signal. If you select One
multidimensional signal, the block outputs an M-by-N-by-P
color video signal, where P is the number of color planes, at one
port. If you select Separate color signals, additional ports
appear on the block. Each port outputs one M-by-N plane of an
RGB video stream.
1-465
Image From Workspace
The Data Types pane of the Image From Workspace dialog box appears
as shown in the following figure.
1-466
Image From Workspace
Word length
Specify the word length, in bits, of the fixed-point output data
type. This parameter is only visible if, from the Output data
type list, you select Fixed-point.
Set fraction length in output to
Specify the scaling of the fixed-point output by either of the
following two methods:
• Choose Best precision to have the output scaling
automatically set such that the output signal has the best
possible precision.
• Choose User-defined to specify the output scaling in the
Fraction length parameter.
This parameter is only visible if, from the Output data type list,
you select Fixed-point or when you select User-defined.
Fraction length
For fixed-point output data types, specify the number of fractional
bits, or bits to the right of the binary point. This parameter is
only visible when you select Fixed-point or User-defined for
the Output data type parameter and User-defined for the Set
fraction length in output to parameter.
User-defined data type
Specify any built-in or fixed-point data type. You can specify
fixed-point data types using the sfix, ufix, sint, uint, sfrac,
and ufrac functions from the Fixed-Point Designer library. This
parameter is only visible when you select User-defined for the
Output data type parameter.
1-467
Image From Workspace
1-468
Image Pad
Library Utilities
visionutilities
Description The Image Pad block expands the dimensions of a signal by padding its
rows, columns, or both. To crop an image, you can use the Simulink
Selector block, DSP System Toolbox Submatrix block, or the Image
Processing Toolbox imcrop function.
Complex Values
Port Input/Output Supported Data Types
Supported
Image / M-by-N matrix of • Double-precision floating Yes
I intensity values or an point.
M-by-N-by-P color video
• Single-precision floating
signal, where P is the
point.
number of color planes.
• Fixed point.
• Boolean.
• 8-, 16-, 32-bit signed integer.
• 8-, 16-, 32-bit unsigned
integer.
PVal Scalar value that Same as I port. Yes
represents the constant
pad value.
Output Padded scalar, vector, or Same as I port. Yes
matrix.
1-469
Image Pad
• Method = Constant
• Pad value source = Specify via dialog
• Pad value = 0
• Specify = Output size
• Add columns to = Left
• Output row mode = User-specified
• Number of output columns = 6
• Add rows to = No padding
1-470
Image Pad
• Method = Replicate
• Specify = Pad size
• Add columns to = Both left and right
• Number of added columns = 2
• Add rows to = Both top and bottom
• Number of added rows = [1 3]
1-471
Image Pad
The border values of the input signal are replicated on the top, bottom,
left, and right of the input signal so that the output is a 7-by-7 matrix.
The values in the corners of this output matrix are determined by
replicating the border values of the matrices on the top, bottom, left and
right side of the original input signal.
• Method = Symmetric
• Specify = Pad size
• Add columns to = Both left and right
1-472
Image Pad
The block flips the original input matrix and each matrix it creates
about their top, bottom, left, and right sides to populate the 7-by-13
output signal. For example, in the preceding figure, you can see how
the block flips the input matrix about its right side to create the matrix
directly to its right.
Pad Using a Circular Repetition of Elements
Suppose you want to pad your input signal using a circular repetition of
its values. Your input signal is defined as follows:
1-473
Image Pad
• Method = Circular
• Specify = Output size
• Add columns to = Both left and right
• Number of output columns = 9
• Add rows to = Both top and bottom
• Number of output rows = 9
The block repeats the values of the input signal in a circular pattern to
populate the 9-by-9 output matrix.
1-474
Image Pad
Dialog The Image Pad dialog box appears as shown in the following figure.
Box
1-475
Image Pad
Method
Specify how you want the block to pad your signal. The data type
of the input signal is the data type of the output signal.
Use the Method parameter to specify how you pad the input
signal.
• Constant — Pad with a constant value
• Replicate — Pad by repeating its border values
• Symmetric — Pad with its mirror image
• Circular — Pad using a circular repetition of its elements
1-476
Image Pad
If you select Output size, you can enter the total number of
output columns and rows. This setting enables you to pad the
input signal. See the previous section for descriptions of the Add
columns to and Add rows to parameters.
Add columns to
The Add columns to parameter controls the padding at the left,
right or both sides of the input signal.
• Left — The block adds additional columns on the left side.
• Right — The block adds additional columns on the right side.
• Both left and right — The block adds additional columns to
the left and right side.
• No padding — The block does not change the number of
columns.
1-477
Image Pad
1-478
Image Pad
1-479
Image Pad
1-480
Insert Text
Description The Insert Text block draws formatted text or numbers on an image or
video stream. The block uses the FreeType 2.3.5 library, an open-source
font engine, to produce stylized text bitmaps. To learn more about the
FreeType Project, visit http://www.freetype.org/. The Insert Text
block does not support character sets other than ASCII.
The Insert Text block lets you draw one or more instances of one or
more strings, including:
1-481
Insert Text
%c and %s:
%f:
1-482
Insert Text
1-483
Insert Text
1-484
Insert Text
When you use the row-major functionality, you must consider the
following issues:
• When you select this check box, the first two signal dimensions of the
Insert Text block’s input are swapped.
• All Computer Vision System Toolbox software blocks can be used to
process data that is in the row-major format, but you need to know
the image dimensions when you develop your algorithms.
For example, if you use the 2-D FIR Filter block, you need to verify
that your filter coefficients are transposed. If you are using the
Rotate block, you need to use negative rotation angles, etc.
• Only three blocks have the Input image is transposed (data
order is row major) check box. They are the Chroma Resampling,
Deinterlacing, and Insert Text blocks. You need to select this check
box to enable row-major functionality in these blocks. All other blocks
must be properly configured to process data in row-major format.
1-485
Insert Text
Step 1:
Create block diagram Algorithm
blocks
Step 2:
Replace source, transpose, and
Embedded sink blocks with target source Embedded
target source and sink blocks that produce target sink
block data in row-major format block
See the DM642 EVM Video ADC and DM642 EVM Video DAC reference
pages.
Dialog The Main pane of the Insert Text dialog box appears as shown in the
Box following figure.
1-486
Insert Text
1-487
Insert Text
Text
Specify the text string to be drawn on the image or video stream.
This parameter can be a single text string, such as 'Figure1', a
cell array of strings, such as {'Figure1','Figure2'}, or an ANSI
C printf-style format specifications, such as %s.. To create a
Select port enter a cell array of strings. To create a Variables
port, enter ANSI C printf-style format specifications, such as
%d, %f, or %s.
When you enter a cell array of strings, the Insert Text block does
not display all of the strings simultaneously. Instead, the Select
port appears on the block to let you indicate which text string
to display. The input to this port must be a scalar value, where
1 indicates the first string. If the input is less than 1 or greater
than one less than the number of strings in the cell array, no text
will be drawn on the image or video frame.
1-488
Insert Text
The following table describes how to format the color of the text
strings, which depend on the block input and the number of
strings you want to insert. Color values for a floating-point data
type input image must be between 0 and 1. Color values for an
8-bit unsigned integer data type input image must between 0 and
255.
1-489
Insert Text
Location source
Indicate where you want to specify the text location. Your choices
are:
• Specify via dialog — the Location [x y] parameter appears
on the dialog box.
• Input port — the Location port appears on the block.
Location [x y]
Specify the text location. This parameter is visible if, for the
Location source parameter, you select Specify via dialog.
Tunable.
1-490
Insert Text
insert. You can specify more than one location regardless of how
many text strings you specify, but the only way to get a different
text string at each location is to use the %s option for the Text
parameter to specify a set of text strings. You can enter negative
values or values that exceed the dimensions of the input image or
video frame, but the text might not be visible.
Opacity source
Indicate where you want to specify the text’s opaqueness. Your
choices are:
• Specify via dialog — the Opacity parameter appears on
the dialog box.
• Input port — the Opacity port appears on the block.
Opacity
Specify the opacity of the text. This parameter is visible if, for the
Opacity source parameter, you select Specify via dialog.
Tunable.
1-491
Insert Text
The following table describes how to format the opacity of the text
strings depending on the number of strings you want to insert.
1-492
Insert Text
The Font pane of the Insert Text dialog box appears as shown in the
following figure.
1-493
Insert Text
1-494
Insert Text
Font face
Specify the font of your text. The block populates this list with the
fonts installed on your system. On Windows, the block searches
the system registry for font files. On UNIX, the block searches the
X Server’s font path for font files.
Font size (points)
Specify the font size.
Anti-aliased
Select this check box if you want the block to smooth the edges of
the text. This can be computationally expensive. If you want your
model to run faster, clear this check box.
1-495
Insert Text (To Be Removed)
Description
Note This Insert Text block will be removed in a future release. It uses
the zero-based, [row column] coordinate system. It is recommended that
you replace this block with the updated Insert Text block that uses the
one-based, [x y] coordinate system.
1-496
Label
Description The Label block labels the objects in a binary image, BW, where the
background is represented by pixels equal to 0 (black) and objects are
represented by pixels equal to 1 (white). At the Label port, the block
outputs a label matrix that is the same size as the input matrix. In the
label matrix, pixels equal to 0 represent the background, pixels equal
to 1 represent the first object, pixels equal to 2 represent the second
object, and so on. At the Count port, the block outputs a scalar value
that represents the number of labeled objects.
Complex
Port Input/Output Supported Data Types Values
Supported
BW Vector or matrix that Boolean No
represents a binary image
Label Label matrix • 8-, 16-, and 32-bit unsigned No
integer
Count Scalar that represents the Same as Label port No
number of labeled objects
1-497
Label
If, for the Connectivity parameter, you select 8, the block considers
the white pixels marked by black circles to be connected.
1-498
Label
Dialog The Label dialog box appears as shown in the following figure.
Box
Connectivity
Specify which pixels are connected to each other. If you want a
pixel to be connected to the pixels on the top, bottom, left, and
right, select 4. If you want a pixel to be connected to the pixels on
the top, bottom, left, right, and diagonally, select 8.
Output
Determine the block’s output. If you select Label matrix and
number of labels, the Label and Count ports appear on the
block. The block outputs the label matrix at the Label port and
the number of labeled objects at the Count port. If you select
1-499
Label
Label matrix, the Label port appears on the block. If you select
Number of labels, the Count port appears on the block.
Output data type
Set the data type of the outputs at the Label and Count ports.
If you select Automatic, the block determines the appropriate
data type for the output. If you select uint32, uint16, or uint8,
the data type of the output is 32-, 16-, or 8-bit unsigned integers,
respectively.
If label exceeds data type size, mark remaining regions using
Use this parameter to specify the block’s behavior if the number
of found objects exceeds the maximum number that can be
represented by the output data type. If you select Maximum
value of the output data type, the remaining regions are
labeled with the maximum value of the output data type. If you
select Zero, the remaining regions are labeled with zeroes. This
parameter is visible if, for the Output data type parameter, you
choose uint16 or uint8.
1-500
Median Filter
Description The Median Filter block replaces the central value of an M-by-N
neighborhood with its median value. If the neighborhood has a center
element, the block places the median value there, as illustrated in the
following figure.
The block has a bias toward the upper-left corner when the
neighborhood does not have an exact center. See the median value
placement in the following figure.
The block pads the edge of the input image, which sometimes causes the
pixels within [M/2 N/2] of the edges to appear distorted. The median
value is less sensitive than the mean to extreme values. As a result, the
Median Filter block can remove salt-and-pepper noise from an image
without significantly reducing the sharpness of the image.
1-501
Median Filter
Complex
Port Input/Output Supported Data Types Values
Supported
I Matrix of intensity values • Double-precision floating point No
• Single-precision floating point
• Fixed point
• Boolean
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Val Scalar value that represents Same as I port No
the constant pad value
Output Matrix of intensity values Same as I port No
If the data type of the input signal is floating point, the output has
the same data type. The data types of the signals input to the I and
Val ports must be the same.
1-502
Median Filter
When M is even, fixed-point signals use the accumulator and output data
types. The accumulator data type store the result of the sum performed
while calculating the average of the two central rows of the input
matrix. The output data type stores the total result of the average.
Complex fixed-point inputs use the accumulator parameters. The
calculation for the sum of the squares of the real and imaginary parts of
the input occur, before sorting input elements. The accumulator data
type stores the result of the sum of the squares.
1-503
Median Filter
Dialog The Main pane of the Median Filter dialog box appears as shown in
Box the following figure.
Neighborhood size
Specify the size of the neighborhood over which the block
computes the median.
1-504
Median Filter
1-505
Median Filter
Pad value
Enter the constant value with which to pad your matrix. This
parameter appears if, for the Pad value source parameter, you
select Specify via dialog. Tunable.
The Data Types pane of the Median Filter dialog box appears as
follows. The parameters on this dialog box becomes visible only when
the dimensions of the neighborhood are even.
1-506
Median Filter
Rounding mode
Select the rounding mode for fixed-point operations.
1-507
Median Filter
Overflow mode
Select the overflow mode for fixed-point operations.
Note Only certain cases require the use of the accumulator and
output parameters. Refer to “Fixed-Point Data Types” on page
1-502 for more information.
Accumulator
Use this parameter to specify the accumulator word and fraction
lengths resulting from a complex-complex multiplication in the
block:
• When you select Same as input, these characteristics match
the related 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. This
block requires power-of-two slope and a bias of 0.
Output
Choose how to specify the output word length and fraction length:
• When you select Same as input, these characteristics match
the related 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. This block
requires power-of-two slope and a bias of 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
1-508
Median Filter
1-509
Opening
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of intensity • Double-precision floating point No
values
• Single-precision floating point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned
integer
Nhood Matrix or vector of ones and Boolean No
zeros that represents the
neighborhood values
Output Scalar, vector, or matrix Same as I port No
of intensity values that
represents the opened
image
The output signal has the same data type as the input to the I port.
1-510
Opening
Dialog The Opening dialog box appears as shown in the following figure.
Box
1-511
Opening
References [1] Soille, Pierre. Morphological Image Analysis. 2nd ed. New York:
Springer, 2003.
1-512
Optical Flow
Description
The Optical Flow block estimates the direction and speed of object
motion from one image to another or from one video frame to another
using either the Horn-Schunck or the Lucas-Kanade method.
Complex
Port Output Supported Data Types Values
Supported
I/I1 Scalar, vector, or matrix of • Double-precision floating point No
intensity values
• Single-precision floating point
• Fixed point (supported when
the Method parameter is set to
Lucas-Kanade)
I2 Scalar, vector, or matrix of Same as I port No
intensity values
|V|^2 Matrix of velocity Same as I port No
magnitudes
V Matrix of velocity Same as I port Yes
components in complex
form
1-513
Optical Flow
To compute the optical flow between two images, you must solve the
following optical flow constraint equation:
I x u + I y v + It = 0
• Horn-Schunck Method
• Lucas-Kanade Method
Horn-Schunck Method
By assuming that the optical flow is smooth over the entire image,
the Horn-Schunck method computes an estimate of the velocity field,
⎧⎪⎛ ∂u ⎞2 ⎛ ∂u ⎞2 ⎛ ∂v ⎞2 ⎛ ∂v ⎞2 ⎫⎪
∫∫ x y t ∫∫ ⎨⎪⎜⎝ ∂x ⎟⎠ + ⎜⎝ ∂y ⎟⎠ + ⎜⎝ ∂x ⎟⎠ + ⎜⎝ ∂y ⎟⎠ ⎬⎪dxdy
2
E= ( I u + I v + I ) dxdy + α
⎩ ⎭
∂u ∂u
In this equation, ∂x and ∂y are the spatial derivatives of the optical
velocity component u, and α scales the global smoothness term. The
Horn-Schunck method minimizes the previous equation to obtain the
velocity field, [u v], for each pixel in the image, which is given by the
following equations:
1-514
Optical Flow
k I x [ I x u xk, y + I y v xk, y + It ]
uxk,+y1 = u x, y −
α 2 + I x2 + I 2y
k I y[ I x u xk, y + I y v xk, y + It ]
vxk,+y1 = v x, y −
α 2 + I x2 + I 2y
In this equation, ⎡uxk, y vxk, y ⎤ is the velocity estimate for the pixel at
⎣ ⎦
⎡ k k ⎤
(x,y), and ⎢⎣u x, y v x, y ⎥⎦ is the neighborhood average of ⎡uxk, y vxk, y ⎤ .
⎣ ⎦
For k=0, the initial velocity is 0.
When you choose the Horn-Schunck method, u and v are solved as
follows:
Lucas-Kanade Method
To solve the optical flow constraint equation for u and v, the
Lucas-Kanade method divides the original image into smaller sections
and assumes a constant velocity in each section. Then, it performs a
weighted least-square fit of the optical flow constraint equation to
1-515
Optical Flow
∑ W 2[ I xu + I yv + It ]2
x∈Ω
⎡ ∑ W 2 I x2 ∑ W 2 I x I y ⎤⎥ ⎡u⎤ = − ⎡⎢∑ W 2 I x It ⎤⎥
⎢ ⎢ ⎥
⎢∑ W 2 I y I x ∑ W 2 I 2y ⎥⎦ ⎣ v ⎦ ⎢⎣∑ W 2 I y It ⎥⎦
⎣
If you are working with fixed-point data types, the kernel values are
signed fixed-point values with word length equal to 16 and fraction
length equal to 15.
1-516
Optical Flow
4 Solve the 2-by-2 linear equations for each pixel using the following
method:
⎡ a b⎤ ⎡ ∑ W 2 I x2 ∑ W 2 I x I y ⎤⎥
• If A = ⎢ ⎥=⎢
⎣ b c ⎦ ⎢⎣ ∑ W 2 I y I x ∑ W 2 I 2y ⎥⎦
a+c 4b2 + (a − c)2
Then the eigenvalues of A are λ i = ± ; i = 1, 2
2 2
Case 1: λ1 ≥ τ and λ 2 ≥ τ
A is nonsingular, the system of equations are solved using
Cramer’s rule.
Derivative of Gaussian
If you set the temporal gradient filter to Derivative of Gaussian, u
and v are solved using the following steps. You can see the flow chart
for this process at the end of this section:
1-517
Optical Flow
4 Solve the 2-by-2 linear equations for each pixel using the following
method:
⎡ a b⎤ ⎡ ∑ W 2 I x2 ∑ W 2 I x I y ⎤⎥
• If A = ⎢ ⎥=⎢
⎣ b c ⎦ ⎢⎣ ∑ W 2 I y I x ∑ W 2 I 2y ⎥⎦
a+c 4b2 + (a − c)2
Then the eigenvalues of A are λ i = ± ; i = 1, 2
2 2
• When the block finds the eigenvalues, it compares them to the
threshold, τ , that corresponds to the value you enter for the
1-518
Optical Flow
Case 1: λ1 ≥ τ and λ 2 ≥ τ
A is nonsingular, so the block solves the system of equations using
Cramer’s rule.
1-519
Optical Flow
Threshold
Gradient Gradient Accumulator data type
Image data type data type data type Output
data type data type
SOLVE FIND
CONVOLUTION PRODUCT SMOOTHING LINEAR MOTION
EQUATIONS VECTORS
Output of Ix, Iy, It Ix^2, Motion
Iy^2, (W^2)Ix^2, vectors
each section (W^2)Iy^2, Eigenvalues
of the IxIy,
IxIt, (W^2)IxIy,
algorithm: (W^2)IxIt,
IyIt
(W^2)IyIt
1-520
Optical Flow
1-521
Optical Flow
You can set the product output, accumulator, gradients, threshold, and
output data types in the block mask.
1-523
Optical Flow
Dialog The Main pane of the Optical Flow dialog box appears as shown in
Box the following figure.
Method
Select the method the block uses to calculate the optical flow.
Your choices are Horn-Schunck or Lucas-Kanade.
Compute optical flow between
Select Two images to compute the optical flow between two
images. Select Current frame and N-th frame back to compute
the optical flow between two video frames that are N frames apart.
1-524
Optical Flow
1-525
Optical Flow
1-526
Optical Flow
The Data Types pane of the Optical Flow dialog box appears as shown
in the following figure. The parameters on this dialog box becomes
visible only when the Lucas-Kanade method is selected.
1-527
Optical Flow
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
Product output
Use this parameter to specify how to designate the product output
word and fraction lengths.
Accumulator
data type Product
data type
MULTIPLIER
Accumulator
or kernel
data type
1-528
Optical Flow
• 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
blocks is 0.
Accumulator
Use this parameter to specify how to designate this accumulator
word and fraction lengths.
CAST ADDER
Input to adder - Accumulator
Image, gradient, Accumulator
data type data type
or product output
data type
1-529
Optical Flow
1-530
Optical Flow
References [1] Barron, J.L., D.J. Fleet, S.S. Beauchemin, and T.A. Burkitt.
Performance of optical flow techniques. CVPR, 1992.
1-531
Projective Transformation (To Be Removed)
Description
1-532
PSNR
Library Statistics
visionstatistics
Description The PSNR block computes the peak signal-to-noise ratio, in decibels,
between two images. This ratio is often used as a quality measurement
between the original and a compressed image. The higher the PSNR,
the better the quality of the compressed, or reconstructed image.
The Mean Square Error (MSE) and the Peak Signal to Noise Ratio
(PSNR) are the two error metrics used to compare image compression
quality. The MSE represents the cumulative squared error between
the compressed and the original image, whereas PSNR represents a
measure of the peak error. The lower the value of MSE, the lower the
error.
To compute the PSNR, the block first calculates the mean-squared error
using the following equation:
In the previous equation, M and N are the number of rows and columns
in the input images, respectively. Then the block computes the PSNR
using the following equation:
⎛ R2 ⎞
PSNR = 10 log10 ⎜ ⎟
⎜ MSE ⎟
⎝ ⎠
1-533
PSNR
Ports
Complex
Port Output Supported Data Types Values
Supported
I1 Scalar, vector, or matrix • Double-precision floating point No
of intensity values
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
I2 Scalar, vector, or matrix Same as I1 port No
of intensity values
Output Scalar value that • Double-precision floating point No
represents the PSNR
For fixed-point or integer input,
the block output is double-precision
floating point. Otherwise, the block
input and output are the same data
type.
1-534
PSNR
Dialog The PSNR dialog box appears as shown in the following figure.
Box
1-535
Read AVI File (To Be Removed)
Library vipobslib
Description
Note The Read AVI File block is obsolete. It may be removed in a
future version of the Computer Vision System Toolbox blocks. Use the
replacement block From Multimedia File.
1-536
Read Binary File
Library Sources
visionsources
Description The Read Binary File block reads video data from a binary file and
imports it into a Simulink model.
This block takes user specified parameters that describe the format of
the video data. These parameters together with the raw binary file,
which stores only raw pixel values, creates the video data signal for a
Simulink model. The video data read by this block must be stored in
row major format.
Note This block supports code generation only for platforms that have
file I/O available. You cannot use this block to do code generation with
Real-Time Windows Target (RTWin).
Complex
Port Output Supported Data Types Values
Supported
Output Scalar, vector, or matrix of • 8-, 16- 32-bit signed integer No
integer values
• 8-, 16- 32-bit unsigned integer
EOF Scalar value Boolean No
1-537
Read Binary File
• Use the Bit stream format parameter to specify whether your data
is planar or packed. If your data is packed, use the Rows and Cols
parameters to define the size of the output matrix.
• Use the Number of output components parameter to specify the
number of components in the binary file. This number corresponds to
the number of block output ports.
• Use the Component, Bits, Rows, and Cols parameters to specify
the component name, bit size, and size of the output matrices,
respectively. The block uses the Component parameter to label
the output ports.
• Use the Component order in binary file parameter to specify how
the components are arranged within the file.
• Select the Interlaced video check box if the binary file contains
interlaced video data.
• Select the Input file has signed data check box if the binary file
contains signed integers.
• Use the Byte order in binary file to indicate whether your binary
file has little endian or big endian byte ordering.
1-538
Read Binary File
Dialog The Read Binary File dialog box appears as shown in the following
Box figure.
File name
Specify the name of the binary file to read. If the location of this
file is on your MATLAB path, enter the filename. If the location of
this file is not on your MATLAB path, use the Browse button to
specify the full path to the file as well as the filename.
Video format
Specify the format of the binary video data. Your choices are
Four character codes or Custom. See “Four Character Code
Video Formats” on page 1-537 or “Custom Video Formats” on page
1-538 for more details.
Four character code
From the drop-down list, select the binary file format.
1-539
Read Binary File
1-540
Read Binary File
1-541
Read Binary File
1-542
Resize
Description The Resize block enlarges or shrinks an image by resizing the image
along one dimension (row or column). Then, it resizes the image along
the other dimension (column or row).
This block supports intensity and color images on its ports. When you
input a floating point data type signal, the block outputs the same data
type.
Shrinking an image can introduce high frequency components into the
image and aliasing might occur. If you select the Perform antialiasing
when resize factor is between 0 and 100 check box, the block
performs low pass filtering on the input image before shrinking it.
Port Description
Complex
Port Input/Output Supported Data Types Values
Supported
Image / M-by-N matrix of intensity • Double-precision floating point No
Input values or an M-by-N-by-P
• Single-precision floating point
color video signal where P is
the number of color planes • Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
ROI Four-element vector [x y • Double-precision floating point No
width height] that defines the (only supported if the input to
ROI the Input port is floating point)
• Single-precision floating point
(only supported if the input to
the Input port is floating point)
1-543
Resize
Complex
Port Input/Output Supported Data Types Values
Supported
ROI Processing
To resize a particular region of each image, select the Enable ROI
processing check box. To enable this option, select the following
parameter values.
If you select the Enable ROI processing check box, the ROI port
appears on the block. Use this port to define a region of interest (ROI)
in the input matrix, that you want to resize. The input to this port must
be a four-element vector, [x y width height]. The first two elements
define the upper-left corner of the ROI, and the second two elements
define the width and height of the ROI.
If you select the Enable ROI processing check box, the Output flag
indicating if any part of ROI is outside image bounds check box
appears in the dialog box. If you select this check box, the Flag port
appears on the block. The following tables describe the Flag port output.
1-544
Resize
Dialog The Main pane of the Resize dialog box appears as shown in the
Box following figure:
1-545
Resize
1-546
Resize
Specify
Specify which aspects of the image to resize. Your choices are
Output size as a percentage of input size, Number of
output columns and preserve aspect ratio, Number of
output rows and preserve aspect ratio, or Number of
output rows and columns.
1-547
Resize
You must enter a scalar value that is greater than zero. The table
below describes the affect of the resize factor value:
number_output_rows =
round(number_input_rows*resize_factor/100);
number_output_cols =
round(number_input_cols*resize_factor/100);
Number of output columns
Enter a scalar value that represents the number of columns you
want the output image to have. This parameter is visible if, for
the Specify parameter, you select Number of output columns
and preserve aspect ratio.
Number of output rows
Enter a scalar value that represents the number of rows you
want the output image to have. This parameter is visible if, for
the Specify parameter, you select Number of output rows and
preserve aspect ratio.
1-548
Resize
When you select Nearest neighbor, the block uses one nearby
pixel to interpolate the pixel value. This option though the most
efficient, is the least accurate. When you select Bilinear, the
block uses four nearby pixels to interpolate the pixel value. When
you select Bicubic or Lanczos2, the block uses 16 nearby pixels to
interpolate the pixel value. When you select Lanczos3, the block
uses 36 surrounding pixels to interpolate the pixel value.
The Resize block performs optimally when you set this parameter
to Nearest neighbor with one of the following conditions:
• You set the Resize factor in % parameter to a multiple of 100.
• Dividing 100 by the Resize factor in % parameter value
results in an integer value.
Perform antialiasing when resize factor is between 0 and 100
If you select this check box, the block performs low-pass filtering
on the input image before shrinking it to prevent aliasing.
Enable ROI processing
Select this check box to resize a particular region of each image.
This parameter is available when the Specify parameter is set
to Number of output rows and columns, the Interpolation
method parameter is set to Nearest neighbor, Bilinear, or
Bicubic, and the Perform antialiasing when resize factor is
between 0 and 100 check box is not selected.
1-549
Resize
The Data Types pane of the Resize dialog box appears as shown in
the following figure.
1-550
Resize
1-551
Resize
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
Interpolation weights table
Choose how to specify the word length of the values of
the interpolation weights table. The fraction length of the
interpolation weights table values is always equal to the word
length minus one:
• When you select Same as input, the word length of the
interpolation weights table values match that of the input to
the block.
• When you select Binary point scaling, you can enter the
word length of the interpolation weights table values, in bits.
• When you select Slope and bias scaling, you can enter the
word length of the interpolation weights table values, in bits.
Product output
1-552
Resize
• 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
blocks is 0.
Accumulator
1-553
Resize
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select Same as 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 blocks 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.
References [1] Ward, Joseph and David R. Cok. "Resampling Algorithms for
Image Resizing and Rotation", Proc. SPIE Digital Image Processing
Applications, vol. 1075, pp. 260-269, 1989.
1-554
Resize (To Be Removed)
Description
Note This Resize block will be removed in a future release. It uses
the zero-based, [row column] coordinate system. It is recommended
that you replace this block with the updated Resize block that uses the
one-based, [x y] coordinate system.
1-555
Rotate
Description Use the Rotate block to rotate an image by an angle specified in radians.
Note This block supports intensity and color images on its ports.
Port Description
Image 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
Angle Rotation angle
Output Rotated matrix
The Rotate block uses the 3-pass shear rotation algorithm to compute
its values, which is different than the algorithm used by the imrotate
function in the Image Processing Toolbox.
1-556
Rotate
You can set the angle values, product output, accumulator, and output
data types in the block mask.
The Rotate block requires additional data types. The Sine table value
has the same word length as the angle data type and a fraction length
that is equal to its word length minus one. The following diagram shows
how these data types are used inside the block.
1-557
Rotate
1-558
Rotate
Dialog The Main pane of the Rotate dialog box appears as shown in the
Box following figure.
Output size
Specify the size of the rotated matrix. If you select Expanded
to fit rotated input image, the block outputs a matrix that
contains all the rotated image values. If you select Same as input
image, the block outputs a matrix that contains the middle part
of the rotated image. As a result, the edges of the rotated image
might be cropped. Use the Background fill value parameter to
specify the pixel values outside the image.
1-559
Rotate
If you select Input port, the Angle port appears on the block.
The block uses the input to this port at each time step as your
rotation angle. The input to the Angle port must be the same data
type as the input to the I port.
Angle (radians)
Enter a real, scalar value for your rotation angle. This parameter
is visible if, for the Rotation angle source parameter, you select
Specify via dialog.
When the rotation angle is a multiple of pi/2, the block uses a more
efficient algorithm. If the angle value you enter for the Angle
(radians) parameter is within 0.00001 radians of a multiple of
pi/2, the block rounds the angle value to the multiple of pi/2 before
performing the rotation.
Maximum angle (enter pi radians to accommodate all positive
and negative angles)
Enter the maximum angle by which to rotate the input image.
Enter a scalar value, between 0 and radians. The block
determines which angle, 0 ≤ angle ≤ max angle , requires the
largest output matrix and sets the dimensions of the output port
accordingly.
1-560
Rotate
input image are always in contact with the top and left sides of
the output image.
This parameter is visible if, for the Output size parameter, you
select Expanded to fit rotated input image, and, for the
Rotation angle source parameter, you select Input port.
Sine value computation method
Specify the value computation method. If you select
Trigonometric function, the block computes sine and cosine
values it needs to calculate the rotation of your image during the
simulation. If you select Table lookup, the block computes and
stores the trigonometric values it needs to calculate the rotation
of your image before the simulation starts. In this case, the block
requires extra memory.
Background fill value
Specify a value for the pixels that are outside the image.
Interpolation method
Specify which interpolation method the block uses to rotate the
image. If you select Nearest neighbor, the block uses the value
of one nearby pixel for the new pixel value. If you select Bilinear,
the new pixel value is the weighted average of the four nearest
pixel values. If you select Bicubic, the new pixel value is the
weighted average of the sixteen nearest pixel values.
The Data Types pane of the Rotate dialog box appears as shown in
the following figure.
1-561
Rotate
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
Angle values
Choose how to specify the word length and the fraction length of
the angle values.
• When you select Same word length as input, the word length
of the angle values match that of the input to the block. In this
1-562
Rotate
This parameter is only visible if, for the Rotation angle source
parameter, you select Specify via dialog.
Product output
1-563
Rotate
• 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
blocks is 0.
Accumulator
1-564
Rotate
Supported
Data
Types
If the data type of the input signal is floating point, the output signal is
the same data type as the input signal.
1-565
Rotate
1-566
SAD (To Be Removed)
Library vipobslib
Description
Note The SAD block is obsolete. It may be removed in a future version
of the Computer Vision System Toolboxsoftware. Use the replacement
block Template Matching.
1-567
Shear
Description The Shear block shifts the rows or columns of an image by a gradually
increasing distance left or right or up or down.
Note This block supports intensity and color images on its ports.
Complex
Port Input/Output Supported Data Types Values
Supported
Image M-by-N matrix of intensity • Double-precision floating point No
values or an M-by-N-by-P color
• Single-precision floating point
video signal where P is the
number of color planes • Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
S Two-element vector that Same as I port No
represents the number of
pixels by which you want to
shift your first and last rows or
columns
Output Shifted image Same as I port No
If the data type of the input to the I port is floating point, the input to
the S port of this block must be the same data type. Also, the block
output is the same data type.
Use the Shear direction parameter to specify whether you want to
shift the rows or columns. If you select Horizontal, the first row
1-568
Shear
1-569
Shear
the new pixel value is the weighted average of the four nearest pixel
values.
The number of pixels the block considers affects the complexity of the
computation. Therefore, the nearest-neighbor interpolation is the most
computationally efficient. However, because the accuracy of the method
is proportional to the number of pixels considered, the bicubic method is
the most accurate. For more information, see “Interpolation Methods”
in the Computer Vision System Toolbox User’s Guide.
If, for the Shear values source parameter, you select Input port, the
S port appears on the block. At each time step, the input to the S port
must be a two-element vector that represents the number of pixels by
which to shift your first and last rows or columns.
If, for the Output size after shear parameter, you select Full, and
for the Shear values source parameter, you select Input port, the
Maximum shear value parameter appears in the dialog box. Use this
parameter to enter a real, scalar value that represents the maximum
number of pixels by which to shear your image. The block uses this
parameter to determine the size of the output matrix. If any input to
the S port is greater than the absolute value of the Maximum shear
value parameter, the block saturates to the maximum value.
1-570
Shear
You can set the product output, accumulator, and output data types
in the block mask.
1-571
Shear
Dialog The Main pane of the Shear dialog box appears as shown in the
Box following figure.
Shear direction
Specify whether you want to shift the rows or columns of the
input image. Select Horizontal to linearly increase the offset of
the rows. Select Vertical to steadily increase the offset of the
columns.
1-572
Shear
The Data Types pane of the Shear dialog box appears as shown in
the following figure.
1-573
Shear
Rounding mode
Select the rounding mode for fixed-point operations.
Overflow mode
Select the overflow mode for fixed-point operations.
Shear values
Choose how to specify the word length and the fraction length of
the shear values.
1-574
Shear
• When you select Same word length as input, the word length
of the shear values match that of the input to the block. In this
mode, the fraction length of the shear values is automatically
set to the binary-point only scaling that provides you with the
best precision possible given the value and word length of the
shear values.
• When you select Specify word length, you can enter the word
length of the shear values, in bits. The block automatically sets
the fraction length to give you the best precision.
• When you select Binary point scaling, you can enter the
word length and the fraction length of the shear values, in bits.
• When you select Slope and bias scaling, you can enter the
word length, in bits, and the slope of the shear values. The bias
of all signals in the Computer Vision System Toolbox blocks is 0.
1-575
Shear
• 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
blocks is 0.
Accumulator
1-576
Shear
• 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 blocks 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 first input to the block at the I port.
• 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 blocks 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.
1-577
Template Matching
Description
The Template Matching block finds the best match of a template within
an input image. The block computes match metric values by shifting a
template over a region of interest or the entire image, and then finds
the best match location.
Port Description
1-578
Template Matching
1-579
Template Matching
1-580
Template Matching
sizevalid=sizeinput – sizetemplate+1
The output at the Metric port for the Match metric mode is of the
valid image size. The output at the Loc port for the Best match index
mode is a two-element vector of indices relative to the top-left corner
of the input image.
The neighborhood metric output at the NMetric port is of the size NxN,
where N must be an odd number specified in the block mask.
1-581
Template Matching
1-582
Template Matching
1-583
Template Matching
1 The block compares nine search points in each step. There is a central
point and eight search points located on the search area boundary.
2 The block decrements the step size by one, after each step, ending
the search with a step size of one pixel.
3 At each new step, the block moves the search center to the best
matching point resulting from the previous step. The number one
blue circles in the figure below represent a search with a starting
step size of three. The number two green circles represent the next
search, with step size of two, centered around the best match found
from the previous search. Finally, the number three orange circles
represent the final search, with step size of one, centered around
the previous best match.
1-584
Template Matching
Three-Step Search
1-585
Template Matching
• True, set to 1 indicating the ROI lies completely inside the valid part
of the input image.
• False, set to 0 indicating the ROI lies completely or partially outside
of the valid part of the input image.
Valid Neighborhood
The neighborhood matrix of metric values is valid inside of the Region
of Interest (ROI). You can use the Boolean flag at the NValid port to
track the valid neighborhood region. The block sets the neighborhood
NValid boolean flag output as follows:
Algorithm The match metrics use a difference equation with general form:
n 1
d p ( x, y) = (∑ xi − yi )
p p
i=1
n n
lnp denotes the metric space ( R , d p ) for R n > 1.
n
d1 ( I j , T ) = ∑ Ii, j − Ti
i=1
1-586
Template Matching
n
2
d2 ( I j , T ) = ∑ Ii, j − Ti
i=1
n
p
d∞ ( I j , T ) = lim
x →∞
∑ Ii, j − Ti
i=1
which simplifies to:
n p
d∞ ( I j , T ) = max Ii, j − Ti
i
Main The Main pane of the Template Matching block appears as shown in
Dialog the following figure.
Box
1-587
Template Matching
1-588
Template Matching
Match metric
Select one of three types of match metrics:
Output
Select one of two output types:
• Metric matrix
Select this option to output the match metric matrix. This option
adds the Metric output port to the block.
• Best match location
Select this option to output the [x y] coordinates for the location of the
best match. This option adds the Loc output port to the block. When
you select Best match location, the Search method, Output
NxN matrix of metric values around best match, and Enable
ROI processing parameter options appear.
Search method
This option appears when you select Best match location for the
Output parameter. Select one of two search methods.
• Exhaustive
• Three-step
1-589
Template Matching
N
This option appears when you select the Output NxN matrix of
metric values around best match check box. Enter an integer
number that determines the size of the N-by-N output matrix centered
around the best match location index. N must be an odd number.
Enable ROI processing
This option appears when you select Best match location for the
Output parameter. Select the check box for the Template Matching
block to perform region of interest processing. When you do so, the
block adds the ROI input port, and the Output flag indicating if ROI
is valid check box appears. The ROI input must have the format [x y
width height], where [x y] are the coordinates of the upper-left corner
of the ROI.
Output flag indicating if ROI is valid
This option appears when you select the Enable ROI processing
check box. Select the check box for the Template Matching block
to indicate whether the ROI is within the valid region of the image
boundary. When you do so, the block adds the ROIValid output port.
Data The Data Types pane of the Template Matching block dialog box
Types appears as shown in the following figure.
Dialog
Box
1-590
Template Matching
1-591
Template Matching
Rounding mode
Select the “Rounding Modes” for fixed-point operations.
Overflow mode
Select the Overflow mode for fixed-point operations.
• Wrap
• Saturate
Product output
Accumulator
Use this parameter to specify how you would like to designate the
accumulator word and fraction lengths.
1-592
Template Matching
When you select Slope and bias scaling, you can enter the Word
length, in bits, and the Slope of the Accumulator. All signals in
the Computer Vision System Toolbox software have a bias of 0.
The block casts inputs to the Accumulator to the accumulator data
type. It adds each element of the input to the output of the adder,
which remains in the accumulator data type. Use this parameter to
specify how to designate this accumulator word and fraction lengths.
Output
Choose how to specify the Word length, Fraction length and Slope
of the Template Matching output:
The Output parameter on the Data Types pane appears when you
select Metric matrix or if you select Best match location and the
Output NxN matrix of metric values around best match check
box is selected.
Reference [1] Koga T., et. Al. Motion-compensated interframe coding for video
conferencing. In National Telecommunications Conference. Nov. 1981,
G5.3.1–5, New Orleans, LA.
1-593
Template Matching
[3] Yu, J., J. Amores, N. Sebe, Q. Tian, "A New Study on Distance
Metrics as Similarity Measurement" IEEE International Conference
on Multimedia and Expo, 2006 .
1-594
Template Matching (To Be Removed)
Description
1-595
To Multimedia File
Library Sinks
visionsinks
Description
The To Multimedia File block writes video frames, audio samples, or
both to a multimedia (.avi, .wav, .wma, .mj2, .mp4, .m4v, or
.wmv) file.
Note This block supports code generation for platforms that have file
I/O available. You cannot use this block with Real-Time Windows
Target software, because that product does not support file I/O.
The generated code for this block relies on prebuilt library files. You
can run this code outside the MATLAB environment, or redeploy it,
but be sure to account for these extra library files when doing so. The
1-596
To Multimedia File
packNGo function creates a single zip file containing all of the pieces
required to run or rebuild this code. See packNGo for more information.
To run an executable file that was generated from a model containing
this block, you may need to add precompiled shared library files to
your system path. See “Simulink Coder”, “Simulink Shared Library
Dependencies”, and “Accelerating Simulink Models” for details.
This block allows you to write .wma/.mwv streams to disk or across a
network connection. Similarly, the From Multimedia File block allows
you to read .wma/.mwv streams to disk or across a network connection.
If you want to play an MP3/MP4 file in Simulink, but you do not
have the codecs, you can re-encode the file as .wma/.mwv, which are
supported by the Computer Vision System Toolbox.
Ports
Port Description
Image M-by-N-by-3 matrix RGB, Intensity, or YCbCr 4:2:2 signal.
R, G, B Matrix that represents one plane of the RGB video stream.
Inputs to the R, G, or B port must have the same dimensions
and data type.
Audio Vector of audio data
Y, Cb, Cr Matrix that represents one frame of the YCbCr video stream.
The Y, Cb, and Cr ports use the following dimensions:
Y: M x N
N
Cb: M x 2
N
Cr: M x 2
1-597
To Multimedia File
Dialog The Main pane of the To Multimedia File block dialog appears as
Box follows.
File name
Specify the name of the multimedia file. The block saves the file
in your current folder. To specify a different file or location, click
the Save As... button.
1-598
To Multimedia File
File type
Specify the file type of the multimedia file. You can select avi,
wav, wma, or wmv.
Write
Specify whether the block writes video frames, audio samples, or
both to the multimedia file. You can select Video and audio,
Video only, or Audio only.
Audio compressor
Select the type of compression algorithm to use to compress the
audio data. This compression reduces the size of the multimedia
file. Choose None (uncompressed) to save uncompressed audio
data to the multimedia file.
1-599
To Multimedia File
Supported For the block to display video data properly, double- and single-precision
Data floating-point pixel values must be between 0 and 1. Any other data
Types type requires the pixel values between the minimum and maximum
values supported by their data type.
Check the specific codecs you are using for supported audio rates.
Supports Complex
Port Supported Data Types Values?
Image • Double-precision floating point No
• Single-precision floating point
• Boolean
• 8-, 16- 32-bit signed integers
• 8-, 16- 32-bit unsigned integers
R, G, B Same as Image port No
1-600
To Multimedia File
Supports Complex
Port Supported Data Types Values?
Audio • Double-precision floating point No
• Single-precision floating point
• 16-bit signed integers
• 32-bit signed integers
• 8-bit unsigned integers
Y, Cb, Cr Same as Image port No
1-601
To Video Display
Library Sinks
visionsinks
Description
The To Video Display block sends video data to your computer screen.
It provides a Windows only, lightweight, high performance, simple
display, which accepts RGB and YCbCr formatted images. This block
also generates code.
The generated code for this block relies on prebuilt .dll files. You can
run this code outside the MATLAB environment, or redeploy it, but be
sure to account for these extra .dll files when doing so. The packNGo
function creates a single zip file containing all of the pieces required to
run or rebuild this code. See packNGo for more information.
To run an executable file that was generated from a model containing
this block, you may need to add precompiled shared library files to
your system path. See “Simulink Coder”, “Simulink Shared Library
Dependencies”, and “Accelerating Simulink Models” for details.
1-602
To Video Display
For the block to display video data properly, double- and single-precision
floating-point pixel values must be from 0 to 1. For any other data type,
the pixel values must be between the minimum and maximum values
supported by their data type.
You can set the display for full screen, normal or, to maintain one-to-one
size. When you save the model, the size and position of the display
window is saved. Any changes while working with the model should
be saved again in order that these preferences are maintained when
you run the model. The minimum display width of the window varies
depending on your system’s font size settings.
This block runs in real-time, and may limit the speed at which video
data displays. It operates and renders video data to the display
independent of the Simulink model. This design allows buffering to the
display, which increases performance. You may notice, the block lags
the model by one or more frames.
Rapid Accelerator
When you set your model to run in “Accelerator Mode”, and do not select
the Open at Start of Simulation option, the block will not be included
during the run, and therefore the video display will not be visible. For
Rapid Accelerator mode, menu preferences are saved only when the
model is compiled. To change any of the menu options, change the
model to run in “Normal Mode”, and re-save it. You can then run in
Rapid Accelerator mode with the new preferences.
Menu The To Video Display block provides menu options to modify viewing
Options preferences for the display. If however, your model is set to run in
“Accelerator Mode”, the menu options will not be available.
View menu
Window Size
1-603
To Video Display
M-by- N
2 matrix.
Image Signal
Specify how the block accepts a color video signal.
Select One multidimensional signal, for the block to accept
an M-by-N-by-3 color video signal at one port.
Select Separate color signals, for additional ports to appear
on the block. Each port accepts one M-by-N plane of an RGB
video stream.
Preferences
Set any preferences available for the Computer Vision System
Toolbox. You can set your model to use hardware acceleration,
by selecting the Use hardware acceleration checkbox in the
1-604
To Video Display
Help menu
Help
Supported
Data
Types
1-605
To Video Display
1-606
Top-hat
Complex
Port Input/Output Supported Data Types Values
Supported
I Vector or matrix of intensity • Double-precision floating No
values point
• Single-precision floating
point
• Fixed point
• Boolean
• 8-, 16-, and 32-bit signed
integer
• 8-, 16-, and 32-bit unsigned
integer
Nhood Matrix or vector of 1s and 0s that Boolean No
represents the neighborhood
values
Output Scalar, vector, or matrix that Same as I port No
represents the filtered image
1-607
Top-hat
If your input image is a binary image, for the Input image type
parameter, select Binary. If your input image is an intensity image,
select Intensity.
Use the Neighborhood or structuring element source parameter to
specify how to enter your neighborhood or structuring element values.
If you select Specify via dialog, the Neighborhood or structuring
element parameter appears in the dialog box. If you select Input
port, the Nhood port appears on the block. Use this port to enter your
neighborhood values as a matrix or vector of 1s and 0s. Choose your
structuring element so that it matches the shapes you want to remove
from your image. You can only specify a it using the dialog box.
Use the Neighborhood or structuring element parameter to
define the region the block moves throughout the image. Specify a
neighborhood by entering a matrix or vector of 1s and 0s. Specify a
structuring element with the strel function from the Image Processing
Toolbox. If the structuring element is decomposable into smaller
elements, the block executes at higher speeds due to the use of a more
efficient algorithm.
1-608
Top-hat
Dialog The Top-hat dialog box appears as shown in the following figure.
Box
1-609
Top-hat
1-610
Trace Boundaries (To Be Removed)
Description
Note This Trace Boundaries block will be removed in a future
release. It uses the zero-based, [row column] coordinate system. It
is recommended that you replace this block with the updated Trace
Boundary block that uses the one-based, [x y] coordinate system.
1-611
Trace Boundary
Description
1-612
Trace Boundary
of boundary pixels
parameter.
x1 y1
x y2
2
x3 y3
. .
. .
. .
x ym
m
1-613
Trace Boundary
Dialog The Trace Boundary dialog box appears as shown in the following figure.
Box
Connectivity
Specify which pixels are connected to each other. If you want a
pixel to be connected to the pixels on the top, bottom, left, and
right, select 4. If you want a pixel to be connected to the pixels
1-614
Trace Boundary
on the top, bottom, left, right, and diagonally, select 8. For more
information about this parameter, see the Label block reference
page.
Initial search direction
Specify the first direction in which to look to find the next
boundary pixel that is connected to the starting pixel.
North
West East
South
North
Northwest Northeast
West East
Trace direction
Specify the direction in which to trace the boundary. Your choices
are Clockwise or Counterclockwise.
1-615
Trace Boundary