| Video and Image Processing Blockset™ | ![]() |
Statistics


Note The 2-D Mean block is obsolete. It may be removed in a future version of the Video and Image Processing Blockset™. Use the replacement block Mean. |
The 2-D Mean block computes the mean of each input matrix or the mean value in a sequence of inputs over time. It can also compute the mean over a particular region of interest (ROI). Use the Running mean check box to choose between the block's basic and running operation.
| Port | Input/Output | Supported Data Types | Complex Values Supported |
|---|---|---|---|
Input | Vector or matrix of intensity values |
| Yes |
Rst | Scalar value | Boolean | 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 — Mean of each M-by-N input matrix or the mean for each element of a series 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. |
| 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.
When you clear the Running mean check box, the block computes the mean of each M-by-N input matrix and outputs it from the block. The equivalent MATLAB® code is mean(u(:)), where u is the input matrix.
The mean of a complex input is computed independently for the real and imaginary components, as shown in the following figure.

When you select the Running mean check box, the block computes the mean for each element of a series 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 mean corresponding to each element,
![]()
and outputs
![]()
For the next input, the block computes the mean for each element of the first three inputs, and so on.
The block resets the running mean whenever a reset event is detected at the optional Rst port. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input.
When the block is reset, the running mean associated with each element is initialized to the value in the corresponding location of the current 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, see Configuration 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 following diagram shows the data types used in the 2-D Mean block for fixed-point signals.

You can set the accumulator and output data types in the dialog box.
The Main pane of the 2-D Mean 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 mean. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input. This parameter is visible only when you select the Running mean 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 you want 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.
The Fixed-point pane of the 2-D Mean dialog box appears as shown in the following figure.

Select the rounding mode for fixed-point operations.
Select the overflow mode for fixed-point operations.
Use this parameter to specify the accumulator 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 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.
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.
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.
Video and Image Processing Blockset | |
Video and Image Processing Blockset | |
Video and Image Processing Blockset | |
Video and Image Processing Blockset | |
Video and Image Processing Blockset | |
Video and Image Processing Blockset | |
| Maximum | Signal Processing Blockset |
Signal Processing Blockset | |
| Minimum | Signal Processing Blockset |
MATLAB |
![]() | 2-D Maximum (Obsolete) | 2-D Median (Obsolete) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |