Products & Services Solutions Academia Support User Community Company

Learn more about Video and Image Processing Blockset   

2-D Variance (Obsolete) - Compute variance of each input matrix

Library

Statistics

Description

The 2-D Variance block computes the variance of each M-by-N input matrix or of a sequence of inputs over time. Use the Running variance check box to choose between the block's basic and running operation.

PortInput/OutputSupported Data TypesComplex Values Supported

Input / I

Vector or matrix of intensity values

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

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

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

Yes

Rst

Signal that triggers a reset event

  • Double-precision floating point

  • Single-precision floating point

  • Boolean

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

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

No

ROI

  • Rectangle — [r c height width]

  • Lines — [r1 c1 r2 c2], where r1 and c1 are the row and column coordinates of the beginning of the line and r2 and c2 are the row and column coordinates of the end of the line.

  • Binary mask — Binary image matrix that enables you to specify which pixels to highlight.

  • Rectangles and lines

    • Double-precision floating point

    • Single-precision floating point

    • Boolean

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

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

  • Binary mask

    • Boolean

No

Label

Matrix where 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.

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

No

Label Numbers

Vector containing the label numbers for the regions for which the block will compute the statistics.

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

No

Output/Out

Without ROI processing — Variance of each M-by-N input matrix or the variance for each element in a sequence of M-by-N inputs.

With ROI processing — Vector of separate statistical values for each ROI or a scalar value that represents the statistical value for all specified ROIs.

Same as Input port

Yes

Flag

Boolean value that indicates whether the ROI is within the image bounds or the label number is within the label matrix.

Boolean

No

Length-M 1-D vector inputs are treated as M-by-1 column vectors.

Basic Operation

If you clear the Running variance check box, the block outputs the variance of each M-by-N input matrix. A scalar input generates a zero-valued output.

For purely real or purely imaginary inputs, the variance of a M-by-N matrix is the square of the standard deviation:

For complex inputs, the variance is given by the following equation:

When the input values are double-precision floating point, the equivalent MATLAB code is var(u(:)), where u is the input.

Running Operation

If you select the Running variance check box, the block computes the variance of a sequence of M-by-N inputs.

For example, suppose A is the first input to the block and B is the second and current input to the block, where

and

The block computes the variance,

and outputs

For the next input, the block computes the variance for each element of the first three inputs, and so on.

Resetting the Running Variance

The block resets the running variance whenever a reset event is detected at the optional Rst port. The reset signal rate must be a positive integer multiple of the rate of the data signal input.

You specify the reset event using the Reset port parameter:

ROI Processing

To calculate the statistical value within a particular region of each image, select the Enable ROI processing check box. This option is not available when the block is in running mode.

Use the ROI type parameter to specify whether the ROI is a binary mask, label matrix, rectangle, or line.

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.

Output = Individual Statistics for Each ROI

Flag Port OutputDescription
0ROI is completely outside the input image.
1ROI is completely or partially inside the input image.

Output = Single Statistic for All ROIs

Flag Port OutputDescription
0All ROIs are completely outside the input image.
1At 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.

Output = Individual Statistics for Each ROI

Flag Port OutputDescription
0Label number is not in the label matrix.
1Label number is in the label matrix.

Output = Single Statistic for All ROIs

Flag Port OutputDescription
0None of the label numbers are in the label matrix.
1At least one of the label numbers is in the label matrix.

Fixed-Point Data Types

The following diagram shows the data types used in the 2-D Variance block for fixed-point signals.

The results of the magnitude squared calculations in the preceding diagram are in the product output data type. You can set the accumulator, product output, and output data types in the dialog box.

Dialog Box

The Main pane of the 2-D Variance dialog box appears as shown in the following figure.

Running variance

Select this check box to enable the block's running operation.

Reset port

Determines the reset event that causes the block to reset the running variance. The reset signal rate must be a positive integer multiple of the rate of the data signal input. This parameter is visible only if you select the Running variance check box.

Enable ROI processing

Select this check box to calculate the statistical value within a particular region of each image. This parameter is not available when the block is in running mode.

ROI type

Specify the type of ROI to use. Your choices are Rectangles, Lines, Label matrix, or Binary mask.

ROI portion to process

Specify whether 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 indicating if ROI is within image bounds

If you select this check box, the Flag port appears on the block. For a description of the Flag port output, see the tables in ROI Processing. This parameter is visible if, for the ROI type parameter, you select Rectangles or Lines.

Output flag indicating if label numbers are valid

If you select this check box, the Flag port appears on the block. For a description of the Flag port output, see the tables in ROI Processing. This parameter is visible if, for the ROI type parameter, you select Label matrix.

The Fixed-point pane of the 2-D Variance 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.

    Note   Refer to Fixed-Point Data Types for more information on how the product output, accumulator, and output data types are used in this block.

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

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

    Note   To compute the required fixed-point settings for this parameter, pick your brightest image and sum all the pixel values across the image. Then, square the value. Specify a word length and fraction length so that the resulting value fits within the Input-sum-squared product data type without overflow. This specification might require picking a large scaling factor (LSB weight , L>1), or, in other words, setting a negative fraction length.

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-squared product, these characteristics match those of the input-squared product.

  • 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. 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 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 scaling against changes by the autoscaling tool

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

See Also

2-D Autocorrelation

Video and Image Processing Blockset software

2-D Correlation

Video and Image Processing Blockset software

Histogram

Video and Image Processing Blockset software

Mean

Video and Image Processing Blockset software

Median

Video and Image Processing Blockset software

Standard Deviation

Video and Image Processing Blockset software

Maximum

Signal Processing Blockset software

Minimum

Signal Processing Blockset software

Variance

Signal Processing Blockset software

var

MATLAB software

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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