The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or docume ntation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Docu mentation, unused, to The MathWorks, Inc.
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
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
March 2007Online onlyNew for Version 2.3 (Release 2007a)
September 2007 Online onlyRevised for Version 2.4 (Release 2007b)
March 2008Online onlyRevised for Version 2.5 (Release 2008a)
October 2008Online onlyRevised for Version 2.6 (Release 2008b)
March 2009Online onlyRevised for Version 2.7 (Release 2009a)
September 2009 Online onlyRevised for Version 2.8 (Release 2009b)
March 2010Online onlyRevised for Version 3.0 (Release 2010a)
Projective TransformationTransform quadrilateral into
ResizeEnlarge or shrink image sizes
Rotate
Perform 2-D FIR filtering on input
matrix
Predict or estimate states of dynamic
systems
Perform 2-D median filtering
transformation to an image
from matching point pairs
another quadrilateral
Rotate im age by specified angle
1-3
1 Block Reference
ShearShift rows or columns of image by
TranslateTranslate image in 2-D plane using
Morphological Operations
linearly varying offset
displacement vector
Sinks
Bottom-hat
ClosingPerform morphological closing on
DilationFind local maxima in binary or
ErosionFind local minima in binary or
LabelLabel connected components in
OpeningPerform morphological opening on
Top-hat
Frame Rate Display
Perform bottom-hat filtering on
intensity or bina r y images
binary or intensity images
intensity images
intensity images
binary images
binary or intensity images
Perform top-hat filtering on intensity
or binary images
Calculate average update rate of
input signal
1-4
To Multimedia File
To Video DisplayDisplay video data
Write video frames and audio
samples to multimedia file
Sources
Sources
VideoToWorkspace
Video Viewer
Write A VI File (Obsolete)Write video frames to uncompressed
Write Binary File
From Multimedia File
Image From File
Image From Workspace
Read Binary File
Video From Workspace
Export video signal to MATLAB
workspace
Display binary, intensity, or RGB
images or video streams
AVI file
Write binary video data to files
Read video frames and audio samples
from compressed multimedia file
Import image from image file
Import image from MATLAB
workspace
Read binary video data from files
Import video signal from MATLAB
workspace
®
Statistics
2-D AutocorrelationCompute 2-D autocorrelation of
input matrix
2-D CorrelationCom pute 2-D cross-correlation of two
input matrices
2-D Histogram (Obsolete)Generate histogram of each input
matrix
2-D Mean (Obsolete)Find mean value of each input
matrix
1-5
1 Block Reference
2-D Median (Obsolete)Find median value of each input
matrix
2-D S ta n d ard Deviation (Obsolete)Find standard deviation of each
input matrix
2-D Variance (Obsolete)Compute variance of each input
matrix
Blob AnalysisCompute statistics for labeled
regions
Find Local MaximaFind local maxima in matrices
Histogram
MaximumFind maximum values in input or
Mean
Median
MinimumFind minimum values in input or
PSNRCompute peak signal-to-noise ratio
Standard DeviationFind standard deviation of each
Variance
Generate histogram of each input
matrix
sequence of inputs
Find mean value of each input
matrix
Find median value of e ach input
matrix
sequence of inputs
(PSNR) between images
input matrix
Compute variance of input or
sequence of inputs
1-6
Text & Graphics
CompositingCombine pixel values of two images,
Draw MarkersDraw markers by embedding
Text & Graphics
overlay one image over another, or
highlight selected pixels
predefined shapes on output image
Transfor
ms
Draw Shapes
Insert Text
2-D DCTCompute 2-D discrete cosine
2-D FFT
2-D IDCTCompute 2-D inverse discrete cosine
2-D IFFT
Gaussian PyramidPerform Gaussian pyramid
gh Lines
Hou
Hough Transform
Draw rectang
circles on im
Draw text on image or video stream.
transform (DCT)
Compute 2-D FFT of input
transform (IDCT)
Compute 2-D IFFT of input
decomposition
Find Cartesian coordinates of lines
described by rho and theta pairs
nd lines in images
Fi
les, lines, polygon s , or
ages
1-7
1 Block Reference
Utilities
Block Processing
Image PadPad signal along its rows, columns,
Variable SelectorSpecify subset of rows or columns
Repeat user-specified operation on
submatrices of input matrix
or both
from input
1-8
2
Blocks — Alphabetical List
2-D Autocorrelation
PurposeCompute 2-D autocorrelation of input matrix
LibraryStatistics
DescriptionThe 2-D Autocorrelation block computes the two-dimensional
autocorrelation of the input matrix. Assume that input matrix A has
dimensions (Ma, Na). The equation for the two-dimensional discrete
autocorrelation is
()()
Na
Ma
Ci jAmn conj Am in j
(, )( , )( (,))
=⋅++
m
−
−
1
1
∑∑
n
=
=
0
0
where
021≤<−iMa
The output of this block has dimensions
Port
Input
Input/OutputSupported Data Types
Vector or matrix of
intensity values or a
scalar, vector, or matrix
that represents one plane
oftheRGBvideostream
OutputAutocorrelation of the
input matrix
If the data type of the input is floating point, the output of the block has
thesamedatatype.
Fixed-Point Data Types
Thefollowingdiagramshowsthedatatypesusedinthe2-D
Autocorrelation block for fixed-point s ignals.
021≤< −jNa
and
.
(,)2121MaNa−−
• Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Same as Input port
.
Complex
Val u es
Supported
Yes
Yes
2-2
2-D Autocorrelation
You can set the product output, accumulator, and output data types in
the b lock mask as discussed in “Dialog Box” on page 2-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” in the Signal Processing
Blockset™ documentation.
2-3
2-D Autocorrelation
Dialog
Box
The Main pane of the 2-D Autocorrelation dialog box appears as shown
in the following figure.
2-4
The Data Types pane of the 2-D Autocorrelation dialog box appears
asshowninthefollowingfigure.
2-D Autocorrelation
Rounding mode
Select the rounding mode f or 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. Refer to “Fixed-Point Data Types” on
page 2-2 and “Multiplication Data Types” in the Signal Pro cessing
2-5
2-D Autocorrelation
Blockset documentation for illustrations depicting the use of the
product output data type in this block:
• When you select
thoseoftheinputtotheblock.
• When you select
word length and the fraction length of the product output, in
bits.
• When you select
word length, in bits, and the slope of the product output. The
bias of all signals in the Video and Image Processing Blockset™
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 2-2 and “Multiplication Data Types” in the Signal Pro cessing
Blockset 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
characteristics match those of the product output.
• When you select
thoseoftheinputtotheblock.
• When you select
word length and the fraction length of the accumulator, in bits.
Same as input, these characteristics match
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Same as product output,these
Same as input, these characteristics match
Binary point scaling,youcanenterthe
2-6
• When you select
word length, in bits, and the slope of the accumulator. The
bias of all signals in the Video and Image Processing Blockset
software is 0.
Output
Choose how to specify the output word length and fraction length.
• When you select
thoseoftheinputtotheblock.
Slope and bias scaling,youcanenterthe
Same as input, these characteristics match
2-D Autocorrelation
• When you select Binary point scaling,youcanenterthe
word length and the fraction length of the output, in bits.
See Also
• When you select
word length, in bits, and the slope of the output. The bias of all
signals in the Video and Image Processing Blockset 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
Tool in the Simulink
2-D Correlation
HistogramVideo and Image Pro cessing
Mean
MedianVideo and Image Processing
Standard Deviation
VarianceVideo and Image Processing
Slope and bias scaling,youcanenterthe
fxptdlg, a reference page on the Fixed-Point
®
documentation.
VideoandImageProcessing
Blockset software
Blockset software
VideoandImageProcessing
Blockset software
Blockset software
VideoandImageProcessing
Blockset software
Blockset software
Maximum
Minimum
Signal P rocess ing Blockset software
Signal P rocess ing Blockset software
2-7
2-D Convolution
PurposeCompute 2-D discrete convolution of two input matrices
LibraryFiltering
vipfilter
Description
The 2-D Convolution block computes the two-dimensional convolution
of two input matrices. Assume that matrix A has dimensions (Ma, Na)
and matrix B has dimensions (Mb, Nb). When the block calculates the
full output size, the equation for the 2-D discrete convolution is
()()
Na
Ma
Ci jAmn Bi m j n
(, )( , )* (,)
=−−
m
−
−
1
1
∑∑
n
=
=
0
0
2-8
Port
I1
I2
where
01≤<+ −iMaMb
01≤< + −jNaNb
and
Input/OutputSupported Data Types
Matrix of intensity
values or a matrix that
represents one plane of
the R G B video stream
• Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Matrix of intensity
Same as I1 port
values or a matrix that
.
Complex
Values
Supported
Yes
Yes
Port
Input/OutputSupported Data Types
represents one plane of
the R G B video stream
2-D Convolution
Complex
Values
Supported
OutputConvolution of the input
matrices
If the data type of the input is floating point, the output of the block has
thesamedatatype.
The dimensions of the output are dictated by the Output size
parameter. Ass um e that the input at port I1 has dimensions (Ma, Na)
and the input at port I2 has dimensions (Mb, Nb). If, for the Outputsize parameter, you choose
convolution with dimensions (Ma+Mb-1, Na+Nb-1). If, for the Outputsize parameter, you choose
central part of the convolution with the same dimensions as the input at
port I1. If, for the Output size parameter, you choose
is only those parts of the convolution that are computed w ithout the
zero-padded edges of any input. This output has dimensions (Ma-Mb+1,
Na-Nb+1). However, if
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))),whereI1p is the
portion of the I1 matrix that aligns with the I2 matrix. See “Example 2”
on page 2-12 for more information.
Note When you select the Output normalized convolution check
box, the block input cannot be fixed point.
Same as I1 port
Full, the output is the full two-dimensional
Same as input port I1, the output is the
Valid, the output
all(size(I1)<size(I2)), the block errors out.
Yes
Fixed-Point Data Types
The following diagram shows the data types used in the 2-D Convolution
block for fixed-point signals.
2-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 2-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” in the Signal Processing
Blockset documentation.
ExamplesExample 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
determine the number of rows and columns of the output m atrix:
The resulting matrix is
2-10
Full, the block uses the following equations to
2-D Convolution
If, for the Output size parameter, you choose Same as input port
, the output is the central part of
I1
the input at port I1, (4,3). However, since a 4-by-3 matrix cannot be
extracted from the exact center of
columns on the top and left side of the
Cfull
with the same dimensions as
, the block leaves more rows and
Cfull
matrix and outputs:
Cfull
If, for the Output size parameter, you choose Valid, the block uses the
following e quations to determine the number of rows and columns of
the output matrix:
2-11
2-D Convolution
In this case, it
Therefore, the
is always possible to extract the exact center of
block outputs
Cfull
.
Example 2
In convolution, the value of an output element is computed as a
weighted sum of neighboring elements.
For example, su p p ose the first inp u t matrix represents an image and
is defined as
I1 = [17241815
23571416
46132022
101219213
11182529]
2-12
The second input matrix also represents an image and is defined as
I2=[816
357
492]
The following figure shows how to compute the (1,1) output element
(zero-based indexing) using these steps:
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.
3 Multiply each element of the rotated I2 matrix by the element of
The Main pane of the 2-D Convolution dialog box appears as shown in
the following figure.
2-15
2-D Convolution
Output size
Output normalized convolution
The Data Types pane of the 2-D Convolution dialog box appears as
shown in the following figure.
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
Na+Nb-1). If you choose
thesamedimensionsastheinputatportI1. Ifyouchoose
output has dimensions (Ma-Mb+1, Na-Nb+1).
If you select this check box, the block’s output is normalized.
Full, the output has dimensions (Ma+Mb-1,
Same as input port I1, the output has
Valid,
2-16
2-D Convolution
2-17
2-D Convolution
Rounding mode
Overflow mode
Product output
Select the rounding mode f or fixed-point operations.
Select the overflow mode for fixed-point operations.
Use this parameter to specify how to designate the product output
word and fraction lengths. Refer to “Fixed-Point Data Types” on
page 2-9 and “Multiplication Data Types” in the Signal Pro cessing
Blockset documentation for illustrations depicting the use of the
product output data type in this block:
• When you select
match those of the first input to the block.
• When you select
word length and the fraction length of the product output, in
bits.
• When you select
word length, in bits, and the slope of the product output. The
bias of all signals in theVideo and Image Processing Blockset
software is 0.
The Product Output inherits its sign according to the inputs. If
either or both input I1 and I2 aresigned,theProductOutput
will be signed. Otherwise, the Product Output is unsigned. The
following table shows all cases.
Sign of Input I1Sign of Input I2Sign of Product
unsignedunsignedunsigned
unsignedsignedsigned
signedunsignedsigned
signedsignedsigned
Same as first input, these characteristics
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Output
2-18
2-D Convolution
Accumulator
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types” on
page 2-9 and “Multiplication Data Types” in the Signal Pro cessing
Blockset 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
characteristics match those of the product output.
• When you select
match those of the first input to the block.
• When you select
word length and the fraction length of the accumulator, in bits.
• When you select
word length, in bits, and the slope of the accumulator. The
bias of all signals in the Video and Image Processing Blockset
software is 0.
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select
match those of the first input to the block.
• When you select
word length and the fraction length of the output, in bits.
• When you select
word length, in bits, and the slope of the output. The bias of all
signals in the Video and Image Processing Blockset software
is 0.
Same as product output,these
Same as first input, these characteristics
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Same as first input, these characteristics
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
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
2-19
2-D Convolution
information, see fxptdlg, a reference page on the Fixed-Point
Tool in th e Simulink documentation.
See Also
2-D FIR FilterVideo and Image Processing Blockset
software
2-20
2-D Correlation
PurposeCompute 2-D cross-correlation of two input matrices
LibraryStatistics
vipstatistics
DescriptionThe 2-D Correlation block computes the two-dimensional
cross-correlation of two input matrices. Assume that matrix A
hasdimensions(Ma,Na)andmatrixBhasdimensions(Mb,Nb).
When the block calculates the full output size, the equation f or the
two-dimensional discrete cross-correlation is
Na
Ma
Ci jAmn conjBm in j
(, )( , )( (,))
=⋅++
m
−
−
1
()()
1
∑∑
n
=
=
0
0
01≤<+ −iMaMb
Port
I1
where
Input/OutputSupported Data Types
Vector or matrix of
intensity values
I2
Scalar, vector, or matrix
of intensity values or a
scalar, vector, or matrix
that represents one plane
oftheRGBvideostream
OutputConvolution of the input
matrices
01≤< + −jNaNb
and
.
• Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Same as I1 port
Same as I1 port
Complex
Valu es
Supported
Yes
Yes
Yes
2-21
2-D Correlation
If the data type of the input is floating point, the output of the block is
thesamedatatype.
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
with dimensions (Ma+Mb-1, Na+Nb-1). If, for the Output size
parameter, you choose
central part of the cross-correlation with the same dimensions as the
inputatportI1. If,fortheOutput size parameter, you choose
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
errors out.
If you select the Normalized output check box, the block’s output
is divided by
I1p is the portion of the I1 matrix that aligns with the I2 matrix. See
“Example 2” on page 2-25 for more information.
Full, the output is the full two-dimensional cross-correlation
Same as input port I1, the output is the
Valid,
all(size(I1)<size(I2)),theblock
sqrt(sum(dot(I1p,I1p))*sum(dot(I2,I2))),where
2-22
Note When you select the Normalized output check box , the block
inputcannotbefixedpoint.
Fixed-Point Data Types
The following diagram shows the data types used in the 2-D Correlation
block for fixed-point signals.
2-D Correlation
You can set the product output, accumulator, and output data types in
the block mask as discussed in “Dialog Box” on page 2-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” in the Signal Processing
Blockset documentation.
Example
s
Example
Suppose
input ma
you cho
the num
The r
1
I1, the first input matrix, has dimensions (4,3). I2, the second
trix, has dimensions (2,2). If, for the Output size parameter,
ose
Full, the block uses the following equations to determine
ber of rows and columns of the output matrix:
esulting matrix is
2-23
2-D Correlation
If, for the Output size parameter, you choose Same as input port
I1
the input at port I1, (4,3). However, since a 4-by-3 matrix cannot be
extracted from the exact center of
columns on the top and left side of the
, the output is the central part of
Cfull
with the same dimensions as
Cfull
, the block leaves more rows and
Cfull
matrix and outputs:
2-24
If, for the Output size parameter, you choose Valid, the block uses the
following e quations to determine the number of rows and columns of
the output matrix:
2-D Correlation
In this case, it is always possible to extract the exact center of
Cfull
.
Therefore, the block outputs
Example 2
In cross-correlation, the value of an output element is computed as a
weighted sum of neighboring elements.
For example, su p p ose the first inp u t matrix represents an image and
is defined as
I1 = [17241815
23571416
46132022
101219213
11182529]
The second input matrix also represents an image and is defined as
I2=[816
357
492]
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.
2-25
2-D Correlation
The ( 2,4) output element from the cross-correlation is
2 Multiply each weight in I2 by the element of I1 underneath.
The Main pane of the 2-D Correlation dialog box appears as shown in
the following figure.
2-29
2-D Correlation
Output size
Normalized output
The Data Types pane of the 2-D Correlation dialog box appears as
shown in the following figure.
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
(Ma+Mb-1, Na+Nb-1). If you choose
output has the same dimensions as the input at port I1. If you
choose
If you select this check box, the block’s output is normalized.
Valid, output has dimensions (Ma-Mb+1, Na-Nb+1).
Full, the output has dimensions
Same as input port I1,the
2-30
2-D Correlation
2-31
2-D Correlation
Rounding mode
Overflow mode
Product output
Select the rounding mode f or fixed-point operations.
Select the overflow mode for fixed-point operations.
Use this parameter to specify how to designate the product output
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 2-22 and “Multiplication Data Types” in the Signal
Processing Blockset documentation for illustrations depicting the
use of the product output data type in this block:
• When you select
match those of the first input to the block.
• When you select
word length and the fraction length of the product output, in
bits.
• When you select
word length, in bits, and the slope of the product output. The
bias of all signals in the Video and Image Processing Blockset
software is 0.
The Product Output inherits its sign according to the inputs. If
either or both input I1 and I2 aresigned,theProductOutput
will be signed. Otherwise, the Product Output is unsigned. The
table below show all cases.
Sign of Input I1Sign of Input I2Sign of Product
unsignedunsignedunsigned
unsignedsignedsigned
signedunsignedsigned
signedsignedsigned
Same as first input, these characteristics
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Output
2-32
2-D Correlation
Accumulator
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 2-22 and “Multiplication Data Types” in the Signal
Processing Blockset 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
characteristics match those of the product output.
• When you select
match those of the first input to the block.
• When you select
word length and the fraction length of the accumulator, in bits.
• When you select
word length, in bits, and the slope of the accumulator. The
bias of all signals in the Video and Image Processing Blockset
software is 0.
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select
match those of the first input to the block.
• When you select
word length and the fraction length of the output, in bits.
• When you select
word length, in bits, and the slope of the output. The bias of all
signals in the Video and Image Processing Blockset software
is 0.
Same as product output,these
Same as first input, these characteristics
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Same as first input, these characteristics
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
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
2-33
2-D Correlation
information, see fxptdlg, a reference page on the Fixed-Point
Tool in th e Simulink documentation.
DescriptionThe 2-D DCT block calculates the two-dimensional discrete cosine
transform of the input signal. T he equation for the two-dimensional
DCT is
N
M
−
−
1
Fmn
(,)()()(,)cos
221
=
CmCnf x y
MN
1
∑∑
y
x
=
=
0
0
xmMy
()
++
2
2
π112)nNπ
(
cos
where
Cm Cn(),() /= 12
for
mn,= 0
and
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.
Port
Input
Input/OutputSupported Data Types
Vector or matrix of
intensity values
• Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
Output2-D DCT of the inputSame as Input port
If the data type of the input signal is floating point, the output of the
block is the same data type.
Cm Cn(),()= 1
otherwise.
Complex
Values
Supported
No
No
2-35
2-D DCT
Use the Sine and cosine computation parameter to specify how the
block computes the sine and cosine terms in the D CT algorithm. If
you select
values during the simulation. If you select
computes and stores the trigonometric values before the simulation
starts. In this case, the block requires extra memory.
Trigonometric fcn, the block computes the sine and cosine
Table lookup,theblock
Fixed-Point Data Types
The following diagram shows the data types used in the 2-D DCT block
for fixed-point signals. Inputs are first cast to the output data type and
stored in the output buffer. Each butterfly stage processes signals in
the accumulator data type, with the final output of the butterfly being
cast back into the output data type.
2-36
2-D DCT
2-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” in the Signal Processing
Blockset documentation. You can set the sine table, product output,
accumulator, and output data types in the block mask as discussed
in the next section.
2-38
2-D DCT
Dialog
Box
The Main pane of the 2-D DCT dialog box appears as shown in the
following figure.
and cosine computation
Sine
ify how the block computes the sine and cosine terms in the
Spec
lgorithm. If you select
DCT a
utes the sine and cosine values during the simulation. If
comp
select
you
Table lookup, the block computes and stores the
Trigonometric fcn,theblock
2-39
2-D DCT
trigonometric values before the simulation starts. In this case, the
block requires extra memory.
The Data Types pane of the 2-D DCT dialog box appears as shown in
the following figure.
2-40
Rounding mode
Select the rounding mode for fixed-point operations. The sine table
values do not obey this parameter; they always round to
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:
2-D DCT
Nearest.
• A rule that inherits a data type, for example,
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 Roun ding mode and
Overflow mode parameters; instead, they are always saturated
and rounded to
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 2-36 and “Multiplication Data Types” for
illustrations depicting the use of the product output d a ta type in
this block. You can set this parameter to:
• A rule that inherits a data type, for example,
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
Click the Show data type assistant buttonto
display the Data Type Assistant, which helps you set the
Product output data type parameter.
Nearest.
Inherit:Same
Inherit:
2-41
2-D DCT
See “Using the Data Type Assistant” in Simulink User’s Guide for
more information.
Accumulator data type
Specify the accumulator data type. See “Fixed-Point Data Types”
on page 2-36 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 via internal rule
Inherit:
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
Click the Show data type assistant buttonto
display the Data Type Assistant, which helps you set the
Accumulator data type parameter.
See “Using the Data Type Assistant” in Simulink User’s Guide for
more information.
Output data type
Specify the output data type. See “Fixed-Point Data Types” on
page 2-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 via internal rule
When you select
Inherit:Inherit via internal rule,the
.
Inherit:
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:
2-42
WLWLfloorDCT length
ideal outputinput
FLFL
ideal outputinput
=+−+(log ())211
=
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)
Click the Show data type assistant buttonto
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specifying Block Output Data Types” in Simulink User’sGuide 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-Po int Tool. For more information,
see
fxptdlg, a reference page on the Fixed-Point Tool in the
Simulink documentation.
2-D DCT
Refere
nces
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
Tool in th e Simulink documentation.
[1] Che
algor
vol. C
[2] Wa
the d
Proc
n, W.H, C.H. Smith, and S.C. Fralick, “A fast computational
ithm for the discrete cosine transform,” IEEE Trans. Commun.,
OM-25, pp. 1004-1009. 1977.
ng, Z. “Fast algorithms for the discrete W transform and for
iscrete Fourier transform,” IEEE Trans. Acoust., Speech, Signal
essing, vol. ASSP-32, pp. 803-816, Aug. 1984.
fxptdlg, a reference page on the Fixed-Point
2-43
2-D DCT
See Also
2-D IDCTVideo and Image Processing Blockset software
2-D FFT
2-D IFFT
Video and Image Processing Blockset software
Video and Image Processing Blockset software
2-44
2-D FFT
PurposeCompute 2-D FFT of input
LibraryTransforms
viptransforms
DescriptionThe 2-D FFT b lock computes the fast Fourier transform (FFT) 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 dimensions of the input matrix, M and
N, must be powers of two. To work with other input sizes, use the Pad
block to pad or truncate these dimensions to powers of two.
The output of the 2-D FFT block is equivalent to the MATLAB
fft2
function:
y = fft2(A) % Equivalent MATLAB code
Computing the FFT of each dimension of the input matrix is equivalent
to calculating the two-dimensional discrete Fourier transform (DFT),
which is defined by the following equation:
ny
N
M
1
1
−
−
Fmnf xyee
where
(,)(,)=
01≤≤−mM
∑∑
y
x
0
0
=
=
01≤≤ −nN
and
−
2
j
M
mx
2ππ
j
−
N
.
2-45
2-D FFT
Port
Description
Supported Data Types
Complex
Values
Supported
Input
Output2-D FFT of the inputSame as input port
Vector or matrix of
intensity v alues
• Double-precision floating
point
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned
integer
Yes
Yes
2-46
2-D FFT
If the input signal data type is floating point, the data type of the output
signal uses the same floating-point data type. Otherwise, the output
can be any fixed-point data type.
Optimizing the Table of Trigonometric Values
The block computes all the possible trigonometric values of the twiddle
factor
k
2π
j
−
K
e
where K is the greater value of either M or N and
kK=−01,,
Theblockstoresthesevaluesinatableandretrievesthemduring
simulation. You can optimize the table of trigonometric values for
memory or speed using the Optimize table for parameter. This
parameter varies the number of table entries as summarized in the
following table.
Optimize Table for Param e ter SettingNum ber of Table Entries for N-Point FFT
Speed
3N/4-floating point
.
Memory
N -fixedpoint
N/4 -floating point
Not supported for fixed point
Ordering Output Column Entries
Use the Output in bit-reversed order parameter to specify the
ordering of the column elements of the output as either linear or
bit-reversed. If you select the Output in bit-reversed order check
box, the row and column elements are output in bit-reversed order.
Thus, the mth row element appears at the kth position, where k is the
bit reversed value of m.Also,thenth column element appears at thelth position, where l is the bit reversed value of n.Ifyouclearthe
Output in bit-reversed order check box, the channel elements are
output in linear order.
2-47
2-D FFT
Note The 2-D FF T block calculates its output in bit-reversed order.
Linearly ordering the 2-D FFT block output requires an extra
bit-reversal operation. Thus, in many situations, you can increase the
speed of the 2-D FFT block by selecting the Output in bit-reversedorder check box.
For more information ordering of the output, see “Bit-Reversed Order”
on page 2-50. The 2-D FFT block bit-reverses the order of both the
columns and the rows.
Algorithms Used for FFT Computation
Which algorithms the block uses depends on whether the block input is
floating-point or fixed-point, real or complex. The choice of algorithms
is also affected by whether you want the output in linear or bit-reversed
order. Based on these specifications, the block can use any of the
following algorithms:
2-48
• Bit-reversal operation
• Double-signal algorithm
• Half-length algorithm
• Radix-2 decimation-in-time (DIT) algorithm
• Radix-2 decimation-in-frequency (DIF) algorithm
Floating-Point Signals
Complexity
of Input
Complex
Complex
Output
Ordering
LinearBit-reversal operation and radix-2
Bit-reversedRadix-2 DIF
Algorithms Used for FFT
Computation
DIT
Floating-Point Signals ( Con tinued)
2-D FFT
Complexity
of Input
RealLinearBit-reversal operation and radix-2
RealBit-reversedRadix-2 DIF in conjunction with
Fixed-Point Signals
Complexity
of Input
Real or complexLine arBit-reversal operation and radix-2
Real or complexBit-reversedRadix-2 DIF
Output
Ordering
Output
Ordering
Algorithms Used for FFT
Computation
DIT in conjunction with the
half-length and double-signal
algorithms
the half-length and double-signal
algorithms
Algorithms Used for FFT
Computation
DIT
Fixed-Point Data Types
The follo wing diagrams s how the data types used in the 2-D FFT block
for fixed-point signals. You can set the sine table, accumulator, product
output, and output data types displayed in the diagrams in the 2-D FFT
dialog box as discussed in “Dialog Box” on page 2-53.
The block first casts inputs to the output data type and stores them 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 twiddle factor
values before each butterfly stageinadecimation-in-time FFT and
after each butterfly stage in a decimation-in-frequency FFT.
2-49
2-D FFT
The output of the multiplier appears in the accumulator data type
because both of the inputs to the multiplier are complex. For details on
the complex multiplication performed, refer to “Multiplication Data
Types” in the Signal Processing Blockset documentati on .
ExampleBit-Reversed Order
Two numbers are bit-reversed values of each other when the binary
representation of one is the mirror image of the binary representation
of the other. For example, in a three-bit syste m , one and four
are bit-reversed values of each other because the three-bit binary
representation of one, 001, is the mirror image of the three-bit binary
2-50
2-D FFT
representation of four, 100. The following diagram shows the row
indices in linear order. To put them in bit-reversed order
1 Translate the in
minimum number
bits is three be
2 Find the mirror image of each binary entry, and write it beside the
original binary representation.
3 Translate the indices back to their decimal representation.
The row indi
If, on the 2-D FFT block parameters dialog box, you select the Outputin 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.
iii iii84 2406 2745 11176 9411 922 13184 25..........−−+−++ −−−−+...
... .. ..
ii i iii−−−−−
... .. .
iiii i
2
iiiii
iiiii
3
4
5
67
13405
ii
+
45 111 27
...
+−+
ii
−
ii
..
Output in bit-reversed order
0
2451310 510 513 9 0 415 9 21 615 9 21 613 9
91143
−−
−−
++ −
+
1
−−+− −− −+
ii
ii
i
iiiiii..... . ....−− −+ − +−+−−+99434 05
iiii
2
ii i ii... .. ..
1114 31163 59177 239177 239163 59
ii iiii
−−+−−−+−+
245 44 3 10 45 7 16 412 4 11 45 5 1 4
iii i ii
4419 2455 14125 11357 16434 05
iiiiii
5 6 13 111 5 1127 6 6 62 63 4 8 76 2 13
........ .
3
++−+−
+−+−−+
4
... .. ...
.. .. .. ..
... .. ..
5
67
..
ii
+
⎤
⎥
⎥
⎥
⎥
⎥
⎥
.
i
⎥
⎥
⎥
⎥
⎥
⎦
⎤
⎥
⎥
⎥
⎥
⎥
⎥
⎥
i
⎥
⎥
⎥
⎥
⎦
2-52
2-D FFT
Dialog
Box
The Main pane of the 2-D FFT dialog box a ppears as shown in the
following figure.
2-53
2-D FFT
Optimize table for
Optimize the table of twiddle factor values for
This parameter must be set to
Output in bit-reversed order
Designate the order of the output channel elements relative to
the ordering of the input elements. When selected, the output
channel elements appear in bit-reversed order relative to the
input ordering. Otherwise, the output column elements display
in linear order relative to the input ordering. Linearly ordering
the output requires extra data sorting manipulation. For more
information, s ee “Bit-Reversed Order” on page 2-50.
Divide butterfly outputs by two
When you select this parameter, the output of each butterfly of
the FFT is divided by two.
The Data Types pane of the 2-D FFT dialog box appears as shown in
the following figure.
Speed for fixed-point signals.
Speed or Memory.
2-54
2-D FFT
Roun
ding mode
ect the rounding mode for fixed-point operations. The sine
Sel
le values do not obey this parameter; instead, they always
tab
nd to
rou
Nearest.
2-55
2-D FFT
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,
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 Roun ding mode and
Overflow mode parameters; instead, they are always saturated
and rounded to
Product output data type
Specify the product output data type. See “Fixed-Point Data
Types” on page 2-49 and “Multiplication Data Types” for
illustrations depicting the use of the product output d a ta type in
this block. You can set this parameter to:
• A rule that inherits a data type, for example,
Inherit via internal rule
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
Click the Show data type assistant buttonto
display the Data Type Assistant, which helps you set the
Product output data type parameter.
Nearest.
Inherit:Same
Inherit:
2-56
See “Using the Data Type Assistant” in Simulink User’s Guide for
more information.
Accumulator data type
Specify the accumulator data type. See “Fixed-Point Data Types”
on page 2-49 for illustrations depicting the use of the accumulator
data type in this block. You can set this parameter to:
2-D FFT
• A rule that inherits a data type, for example,
Inherit via internal rule
Inherit:
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
Click the Show data type assistant buttonto
display the Data Type Assistant, which helps you set the
Accumulator data type parameter.
See “Using the Data Type Assistant” in Simulink User’s Guide for
more information.
Output data type
Specify the output data type. See “Fixed-Point Data Types” on
page 2-49 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 via internal rule
When you select
Inherit:Inherit via internal rule,the
.
Inherit:
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:
WLWLfloorFFT length
ideal outputinput
FLFL
ideal outputinput
g these ideal results, the internal rule then selects word
Usin
gths and fraction lengths that are appropriate for your
len
=+−+(log ())211
=
2-57
2-D FFT
hardware. For more information, see “Inherit via Internal
Rule”.
• An expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
Click the Show data type assistant buttonto
display the Data Type Assistant, which helps you set the
Output data type parameter.
See “Specifying Block Output Data Types” in Simulink User’sGuide 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
Tool in th e Simulink documentation.
fxptdlg, a reference page on the Fixed-Point
2-58
See Also
2-D DCTVideo and Image Processing Blockset software
2-D IDCTVideo and Image Processing Blockset software
I using the coefficient matrix H or the coefficient vectors HH
Complex
Valu es
Supported
I
H
HH
HV
PVa
OutputScalar, vector, or matrix
Vector or matrix of
intensity values
Matrix of filter coefficientsSame as I port.
Vector of filter coefficientsSame as I port. The input to ports
Vector of filter coefficientsSame as I port. The input to ports
l
Scalar value that
represents the constant
pad value
of filtered values
• Double-precision floating point
• Single-precision floating point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit unsigned integer
HH and HV must be the same
data type.
HH and HV must be the same
data type.
ut must have the same data
Inp
eastheinputtoIport.
typ
Same as I port.
Yes
Yes
Yes
Yes
Yes
Yes
2-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,itwouldtake
xyMN⋅⋅ ⋅
multiply-accumulate (MAC) operations for the block to calculate the
output. For a separable filter, it would only take
()xyMN+⋅⋅
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,
isfilterseparable(H)
filter kernel,
H, and returns S, HCOL and HROW. Here, S is a Boolean
.Theisfilterseparable function takes the
variable that is 1 if the filter is separable and 0 if it is not.
vector of vertical filter coefficients, and
[S, HCOL, HROW] =
HCOL is a
HROW is a vector of horizontal
filter coefficients.
Use the Coefficient source parametertospecifyhowtodefineyour
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
isfilterseparable function, for these parameters. If you select the
HCOL and HROW, the output of 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.
2-60
2-D FIR Filter
If you clear the Separable filter coefficients check b ox and select
a Coefficient source of
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
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
hasdimensions(Mi+Mh-1,Ni+Nh-1). IfyouselectanOutput size of
Same as input port I, the output has the same dimensions as the
inputatportI.IfyouselectanOutput size of
the input image only where the coefficient matrix f its entirely within
it, so no padding is required. The output has dimensions (Mi-Mh+1,
Ni-Nh+1). However, if
Specify via dialog,theCoefficients
Input port,portH appears on the block. Use
Full, the output
Valid,theblockfilters
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
values, select
image, select
repetition of its elements, select
Constant. To pad y our input matrix by repeating its border
Replicate. To pad your input matrix with its mirror
Symmetric. To pad your input matrix using a circular
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 t he dialog box. If you select
Specify via dialog,thePad 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 of
Input port,thePVal
port appears on the block. Use this port to specify the constant value
with which to pad your matrix. T he 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.
2-61
2-D FIR Filter
Use the Filtering based on parameter to specify the algorithm by
which the block filters the input matrix. If you select
set the Output size parameter to
Full, the block filters your input
Convolution and
using the following algorithm
Na
Ma
Ci jAmn Hi m j n
(, )( , )* (,)
=−−
m
−
−
1
()()
1
∑∑
n
=
=
0
0
Input (A) data type
Filter coefficient
(H) data type
where
Correlation and set the Output size parameter to Full,theblock
01≤<+ −iMaMh
and
01≤< + −jNaNh
.Ifyouselect
filters your input using the following algorithm
Na
Ma
Ci jAmn conjHm in j
(, )( , )( (,))
=⋅++
m
where
01≤<+ −iMaMh
−
−
1
()()
1
∑∑
n
=
=
0
0
and
01≤< + −jNaNh
.
The imfilter function from the Image Processing Toolbox™ product
similarly performs N-D filtering of multidimension al im ages.
Fixed-Point Data Types
Thefollowingdiagramshowsthedatatypesusedinthe2-DFIRFilter
block for fixed-point signals.
The result of each addition remains
in the accumulator data type
COMPLEX
MULTIPLIER
Accumulator or
Product output
data type
CAST
Accumulator
data type
ADDER
CAST
Accumulator
data type
Output (C)
data type
2-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 2-64.
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” in the Signal Processing
Blockset software documentation.
2-63
2-D FIR Filter
Dialog
Box
The Main pane of the 2-D FIR Filter dialog box appears as shown in
the following figure.
2-64
2-D FIR Filter
Separable filter coefficients
Select this 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.
Coefficient source
Specify h ow to define your filter coefficients. Select
dialog
box. Select
to enter your coefficients in the block parameters dialog
Input port to specify your filter coefficient matrix
using port H or ports HH and HV.
Coefficients
Enter your real or co m plex -valued filter coefficient matrix. This
parameter appears if you clear the Separable filter coefficients
check box and then select a Coefficient source of
dialog
. Tunable.
Vertical coefficients (across height)
Enter the vector of vertical filter coefficients for your separable
filter. This parameter appe ars if you select the Separable filtercoefficients check box and then select aCoefficient source of
Specify via dialog.
Specify via
Specify via
Horizontal coefficients (across width)
Enter the vector o f horizontal filter coefficients for your separable
filter. This parameter appe ars if you select the Separable filtercoefficients check box and then select aCoefficient source of
Specify via dialog.
Output size
This parameter controls the size of the filtered output. If you
choose
If you choose
dimensions as the input at port I If you choose
Full, the output has dimensions (Ma+Mh-1, Na+Nh-1).
Same as input port I, the output has the same
Valid,outputhas
dimensions (Ma-Mh+1, Na-Nh+1).
Padding options
Specify how to pad the boundary of your input matrix. Select
Constant to pad your matrix with a constant value. Select
Replicate to pad your input matrix by repeating its border
2-65
2-D FIR Filter
values. Select Symmetricto pad your input matrix with its mirror
image. Select
repetition of its elements. This parameter appears if you select an
Output size of
Pad value source
Use this parameter to specify how to define your constant
boundary value. Select
in the block parameters dialog box. Select
your constant value using the PVal port. This parameter appears
if you select a Padding options of
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 w ill get an error message if the pad
value is complex when the input image is real.
Filtering based on
Specifythealgorithmbywhichthe block filters the input matrix.
You can select
Circular to pad your input matrix using a circular
Full or Same as input port I.
Specify via dialog to enter your value
Input port to specify
Constant.
Convolution or Correlation.
2-66
The Data Types pane of the 2-D FIR Filter dialog box appears as
shown in the following figure.
2-D FIR Filter
2-67
2-D FIR Filter
Rounding mode
Select the rounding mode f or 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
length of the filter coefficients match that of the input to the
block. In this mode, the block automatically sets the fraction
length of the coefficients 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
word length of the coefficients, in bits. I n this mode, the block
automatically sets the fraction length of the coefficients 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
word length and the fraction length of the coefficients, in bits.
• When you select
the word length, in bits, and the slope of the coefficients. All
signals in the Video and Image Processing Blockset software
have a bias of 0.
The filter coefficients do not obey the Rounding mode and the
Overflow mode parameters; instead, they always satur a t ed and
rounded to
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 2-62 and “Multiplication Data Types” in the Signal
Nearest.
Same word length as input ,theword
Specify word length,youcanenterthe
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenter
2-68
2-D FIR Filter
Processing Blockset documentation for illustrations depicting the
use of the product output data type in this block:
• When you select
thoseoftheinputtotheblock.
• When you select
word length and the fraction length of the product output, in
bits.
• When you select
word length, in bits, and the slope of the product output. All
signals in the Video and Image Processing Blockset software
have a bias of 0.
If you set the Coefficent source (on the Main tab) to
the Product Output will inherit its sign according to the
port
inputs. If either or both input I1 and I2 aresigned,theProduct
Output will be signed. Otherwise, the Product Output is unsigned.
The following table shows all cases.
Sign of Input I1Sign of Input I2Sign of Product
unsignedunsignedunsigned
unsignedsignedsigned
signedunsignedsigned
signedsignedsigned
Same as input, these characteristics match
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Input
Output
Accumulator
Use this parameter to specify how to designate the accumulator
word and fraction lengths. Refer to “Fixed-Point Data Types”
on page 2-62 and “Multiplication Data Types” in the Signal
Processing Blockset 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:
2-69
2-D FIR Filter
• When you select Same as product output,these
characteristics match those of the product output.
• When you select
thoseoftheinputtotheblock.
• When you select
word length and the fraction length of the accumulator, in bits.
• When you select
word length, in bits, and the slope of the accumulator. All
signals in the Video and Image Processing Blockset software
have a bias of 0.
Output
Choose how to specify the word length and fraction length of the
output of the block:
• When you select
thoseoftheinputtotheblock.
• When you select
word length and the fraction length of the output, in bits.
• When you select
word length, in bits, and the slope of the output. All signals
in the Video and Image Processing Blockset software have 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
Tool in th e Simulink documentation.
Same as input, these characteristics match
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
Same as input, these characteristics match
Binary point scaling,youcanenterthe
Slope and bias scaling,youcanenterthe
fxptdlg, a reference page on the Fixed-Point
2-70
See Also
imfilter
Image Processing Toolbox
2-D Histogram (Obsolete)
PurposeGenerate histogram of each input m atrix
LibraryStatistics
Description
Note The 2-D Histogram block is obsolete. It may b e removed in a
future version of the Video and Image Processing Blockset software.
Use the replacement block Histogram.
The 2-D Histogram block computes the frequency distribution of the
elements in each input matrix or in a sequence of inputs over a period
of time. Use the Running histogram check box to select between the
block’s basic and running operation.
The output of the 2-D Histogram block is different than the output of
the
imhist function in the Image Processing Toolbox. For intensity
images, the
imhist function defines the pth bin boundaries as
Ap
(.)
−
15
N
()
−
1
where A is maximum value of the data type, N is the number of bins in
the histogram, and p starts from 1. The 2-D Histogram block defines
bin boundaries as
Ap
()−
1
<≤
N
where A corresponds to the Maximum value of input parameter and
the Minimum value of input parameter is assumed to be 0.
x
≤<
Ap
x
N
Ap
(.)
−
05
N
()
−
1
2-71
2-D Histogram (Obsolete)
Port
Input/OutputSupported Data Types
Complex
Values
Supported
Input / I
Rst
OutputSample-based 1-by-N
Vector or matrix of
intensity values
Signal that triggers a
reset event
vector that represents the
frequency distribution
of each M-by-N input
matrix or the frequency
distributions in a series
of M-by-N inputs
Length-M 1-D vector inputs are tr eated as M-by -1 column vectors.
• Double-precision floating p oint
• Single-precision floating point
• Fixed point
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
• Double-precision floating p oint
• Single-precision floating point
• Boolean
• 8-, 16-, and 32-bit signed integer
• 8-, 16-, and 32-bit unsigned integer
Same as Input port
Yes
No
No
2-72
The block sorts the elements of each input matrix into the number of
discrete bins, n,specifiedbytheNumber of bins parameter. Complex
inputs are sorted by their magnitude squared values.
The histogram value for a given bin represents the frequency of
occurrence of the input values bracketed by that bin. You specify the
upper b oundary of the highest-valued bin in the Maximum value ofinput parameter, B
, and the lower boundary of the lowest-valued
M
2-D Histogram (Obsolete)
bin in the Minimum value of input parameter, Bm. The bins have
equal width of
where n isthenumberofbins. Thecentersarelocatedat
Input values that fall on the border between two bins are sorted 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
input value 7, but not the input value 3. Input values greater than the
Maximum value of input parameterorlessthanMinimum value of
input parameter are sorted into the highest-valued or lowest-valuedbin, respectively. The values you enter for the Maximum value of
input and Minimum value of input parameters must be real-valued
scalar values.
Basic Operation
If you clear the Running histogram check box, the block computes
the f requency distribution of each M-by-N input matrix and outputs a
sample-based 1-by-N vector.
111
⎡
⎢
Forexample,ifyourinputis
parameters as follows:
• Minimum value of input =
• Maximum value of input = 4
• Number of bins = 4
222
⎢
⎢
333
⎣
⎤
⎥
and you set the block
⎥
⎥
⎦
0
2-73
2-D Histogram (Obsolete)
The block outputs [3330].
If you select the Normalized check box, the block scales each element
oftheoutputsothat
Running Operation
If you select the Running histogram check box, the block computes
the f requency distributions in a series of M-by-N inputs.
For example, if your first input is
222
input is
⎡
⎢
333
⎢
⎢
444
⎣
⎤
⎥
⎥
⎥
⎦
sum(v) is 1, where v is the o utput vector.
111
⎡
⎢
222
⎢
⎢
333
⎣
, and you set the block parameters as follows:
⎤
⎥
⎥
⎥
⎦
, your second and current
• Minimum value of input =
• Maximum value of input = 4
• Number of bins = 4
The block outputs [3663]. For the next input, the block computes
the frequency distribution for the first three inputs, and so on.
0
Resetting the Running Histogram
The block resets the running histogram whenever a reset event is
detected at the optional Rst port. The reset signal and the input data
signal must be the same rate.
To enable the Rst port, select the Reset port parameter. You specify
the re set event in the Trigger type parameter, and can be one of the
following:
•
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 0
2-74
2-D Histogram (Obsolete)
- Rises from 0 to a positive value, where the rise is not a continuation
continuation of a fall from a positive value to 0 (see the following
figure)
Falling edge
Falling edge
Falling edge
Falling edge
Not a falling edge because it is
a continuation of a fall from
a positive value to zero.
• Either edge -- Triggers a reset operation when the Rst input is a
Rising edge or Falling edge (as described previously)
2-75
2-D Histogram (Obsolete)
• Non-zero sample -- Triggers a reset operation at each sample time
that the
Note When running simulations in the Simulink MultiTasking mode,
sample-based reset signals have a one-sample latency, and frame-based
reset signals have one frame of latency. Thus, there is a one-sample or
one-frame delay between the time the block detects a reset event, and
when it applies the reset. For more information on latency and the
Simulink tasking modes, see “Configuration Parameters Dialog Box”
in the Simulink documentation.
Rst input is not 0
Dialog
Box
The Main pane of the 2-D Histogram dialog box:
2-76
2-D Histogram (Obsolete)
Minimum value of input
Enter a real-valued s calar value for the lower boundary,
the lowest-valued bin. Tunable.
Maximum value of input
Enter a real-valued scalar value for the upper boundary,
the highest-valued bin. Tunable.
Number of bins
Enter the number of bins, n, in the histogram.
Normalized
If you select this check box, the block normalizes the output vector
(1-norm). Tunable.
Use of this parameter is not supported for fixed-point signals.
Running histogram
Select this check box to enable the block’s running histogram
operation.
Reset port
Enables the Rst input port when selected. The reset signal and
theinputdatasignalmustbethesamerate. Thisparameteris
visible if you select the Running histogram check box.
Bm
BM
,of
,of
Trigger type
The type of event that resets the running histogram. For more
information, see “Resetting the Running Histogram” on page
2-74. This parameter is enabled only when you set the Resetport parameter.
The Fixed-point pane of the 2-D Histogram dialog bo x:
2-77
2-D Histogram (Obsolete)
2-78
Note The
inputs,
Roundi
Overf
Prod
which are sorted by squared magnitude.
ng mode
Selec
low mode
Selec
uct output
Use t
word
• Whe
fixed-point paramete rs are only used for fixed-point complex
t the rounding mode for fixed-point operations.
t the overflow mode for fixed-point operations.
his parameter to specify how to designate the product output
and fraction lengths:
nyouselect
se of the input to the block.
tho
Same as input, these characteristics match
2-D Histogram (Obsolete)
• When you select Binary point scaling,youcanenterthe
word length and the fraction length of the product output, in
bits.
• When you select
word length, in bits, and the slope of the product output. This
block requires power-of-two slope and a bias of 0.
Accumulator
Use this parameter to specify the accumulator word and fraction
lengths resulting from a complex-complex multiplication in the
block:
• When you select
characteristics match those of the product output.
• When you select
thoseoftheinputtotheblock.
• When you select
word length and the fraction length of the accumulator, in bits.
• When you select
word length, in bits, and the slope of the accumulator. This
block requires power-of-two slope and a bias of 0.
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-Po int Tool. For more information,
see
fxptdlg, a reference page on the Fixed-Point Tool in the
DescriptionThe 2-D IDCT block calculates the two-dimensional inverse
discrete cosine transform of the input signal. The equation for the
two-dimensional IDCT is
N
M
−
−
1
fxy
(, )( ) () ( , )cos
221
=
MN
1
CmCnFmn
∑∑
n
m
=
=
0
0
xmMy
()
π112)nNπ
++
2
cos
2-D IDCT
2
(
Port
Input
where F(m,n) is the DCT of the signal f(x,y) and
mn,= 0
Cm Cn(),()= 1
and
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.
Input/OutputSupported Data Types
Vector or matrix of
intensity values
• Double-precision floating
point
• Single-precision floating
point
• Fixed point
• 8-, 16-, 32-bit signed integer
• 8-, 16-, 32-bit un sign ed
integer
Cm Cn(),()=
Complex
Valu es
Supported
No
1
2
for
2-81
2-D IDCT
Port
Input/OutputSupported Data Types
Complex
Valu es
Supported
Output2-D IDCT of the inputSame as Input port
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
values during the simulation. If you select
computes and stores the trigonometric values before the simulation
starts. In this case, the block requires extra memory.
Trigonometric fcn, the block computes the sine and cosine
Fixed-Point Data Types
Thefollowingdiagramshowsthedatatypesusedinthe2-DIDCTblock
for fixed-point signals. Inputs are first cast to the output data type and
stored in the output buffer. Each butterfly stage processes signals in
the accumulator data type, with the final output of the butterfly being
cast back into the output data type.
No
Table lookup,theblock
2-82
2-D IDCT
2-83
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
intheaccumulatordatatype. Fordetails on the com plex multiplication
performed, refer to “Multiplication Data Types” in the Signal Processing
Blockset documentation. You can set the sine table, product output,
accumulator, and output data types in the block mask as discussed
in the next section.
2-84
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.