| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Video and Image Processing Blockset |
| Contents | Index |
| Learn more about Video and Image Processing Blockset |
Statistics

Note The 2-D Standard Deviation block is obsolete. It may be removed in a future version of the Video and Image Processing Blockset software. Use the replacement block Standard Deviation. |
The 2-D Standard Deviation block computes the standard deviation of each M-by-N input matrix or of a sequence of inputs over time. Use the Running standard deviation check box to select between the block's basic and running operation. This block's functionality is different from the Signal Processing Blockset Standard Deviation block, which computes the standard deviation of each column in the input.
| Port | Input/Output | Supported Data Types | Complex Values Supported |
|---|---|---|---|
Input / I | Vector or matrix of intensity values |
| Yes |
Rst | Signal that triggers a reset event |
| No |
ROI |
| Rectangles and lines —
Binary mask —
| 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. |
| No |
Label Numbers | Vector containing the label numbers for the regions for which the block will compute the statistics. |
| No |
Output / Out | Without ROI processing — Standard deviation of each M-by-N input matrix, or the standard deviation of 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.
If you clear the Running standard deviation check box, the block outputs the standard deviation of each M-by-N input matrix.
For purely real or purely imaginary inputs, the standard deviation is the square root of the variance and is given by the following equation:

where µ is the mean of the input matrix u. For complex inputs, the block outputs the total standard deviation of the input matrix, which is the square root of the total variance.
![]()
The total standard deviation is not equal to the sum of the real and imaginary standard deviations.
If you select the Running standard deviation check box, the block computes the standard deviation 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 standard deviation as
![]()
and outputs
![]()
For the next input, the block computes the standard deviation for each element of the first three inputs, and so on.
The block resets the running standard deviation 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:
None — Disables the Rst port
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
Rises from 0 to a positive value, where the rise is not a continuation of a rise from a negative value to 0 (see the following figure)

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 0
Falls from 0 to a negative value, where the fall is not a continuation of a fall from a positive value to 0 (see the following figure)

Either edge — Triggers a reset operation when the Rst input is a Rising edge or Falling edge (as described previously).
Non-zero sample — Triggers a reset operation at each sample time that the Rst input is not 0.
Note When running simulations in the Simulink MultiTasking mode, reset signals have a one-sample latency. Therefore, when the block detects a reset event, there is a one-sample delay at the reset port rate before the block applies the reset. For more information on latency and the Simulink tasking modes, seeConfiguration Parameters Dialog Box in the Simulink documentation. |
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 rectangle, line, label matrix, or binary mask. A binary mask is a binary image that enables you to specify which pixels to highlight, or select. In a 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. When the ROI type parameter is set to Label matrix, the Label and Label Numbers ports appear on the block. 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 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.
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.
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 Output | Description |
|---|---|
| 0 | ROI is completely outside the input image. |
| 1 | ROI is completely or partially inside the input image. |
Output = Single statistic for all ROIs
| Flag Port Output | Description |
|---|---|
| 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.
Output = Individual statistics for each ROI
| Flag Port Output | Description |
|---|---|
| 0 | Label number is not in the label matrix. |
| 1 | Label number is in the label matrix. |
Output = Single statistic for all ROIs
| Flag Port Output | Description |
|---|---|
| 0 | None of the label numbers are in the label matrix. |
| 1 | At least one of the label numbers is in the label matrix. |
The 2-D Standard Deviation dialog box appears as shown in the following figure.

Select this check box to enable the block's running operation.
Determines the reset event that causes the block to reset the running standard deviation. The reset signal rate must be a positive integer multiple of the rate of the data signal input. This parameter is available if you select the Running standard deviation check box.
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.
Specify the type of ROI to use. Your choices are Rectangles, Lines, Label matrix, or Binary mask.
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.
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.
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.
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.
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
| Maximum | Signal Processing Blockset software |
| Minimum | Signal Processing Blockset software |
Signal Processing Blockset software | |
MATLAB software |
![]() | 2-D Minimum (Obsolete) | 2-D Variance (Obsolete) | ![]() |

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 |