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


Note The 2-D Histogram block is obsolete. It may be removed in a future version of the Video and Image Processing Blockset™. 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
![]()
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
![]()
where A corresponds to the Maximum value of input parameter and the Minimum value of input parameter is assumed to be 0.
| 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 |
Output | Sample-based 1-by-N 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 | Same as Input port | No |
Length-M 1-D vector inputs are treated as M-by-1 column vectors.
The block sorts the elements of each input matrix into the number of discrete bins, n, specified by the Number 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 boundary of the highest-valued bin in the Maximum value of input parameter, BM, and the lower boundary of the lowest-valued bin in the Minimum value of input parameter, Bm. The bins have equal width of
![]()
where n is the number of bins. The centers are located at
![]()
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 parameter or less than Minimum value of input parameter are sorted into the highest-valued or lowest-valued bin, respectively. The values you enter for the Maximum value of input and Minimum value of input parameters must be real-valued scalar values.
If you clear the Running histogram check box, the block computes the frequency distribution of each M-by-N input matrix and outputs a sample-based 1-by-N vector.
For example, if your input is
and you set the block parameters as follows:
Minimum value of input = 0
Maximum value of input = 4
Number of bins = 4
The block outputs [3 3 3 0].
If you select the Normalized check box, the block scales each element of the output so that sum(v) is 1, where v is the output vector.
If you select the Running histogram check box, the block computes the frequency distributions in a series of M-by-N inputs.
For example, if your first input is
, your second and current input is
, and you set the block
parameters as follows:
Minimum value of input = 0
Maximum value of input = 4
Number of bins = 4
The block outputs [3 6 6 3]. For the next input, the block computes the frequency distribution for the first three inputs, and so on.
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 reset 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
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 zero 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, 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. |
The Main pane of the 2-D Histogram dialog box:

Enter a real-valued scalar value for the lower boundary,
, of the lowest-valued bin. Tunable.
Enter a real-valued scalar value for the upper boundary,
, of the highest-valued bin.
Tunable.
Enter the number of bins, n, in the histogram.
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.
Select this check box to enable the block's running histogram operation.
Enables the Rst input port when selected. The reset signal and the input data signal must be the same rate. This parameter is visible if you select the Running histogram check box.
The type of event that resets the running histogram. For more information, see Resetting the Running Histogram. This parameter is enabled only when you set the Reset port parameter.
The Fixed-point pane of the 2-D Histogram dialog box:

Note The fixed-point parameters are only used for fixed-point complex inputs, which are sorted by squared magnitude. |
Select the rounding mode for 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:
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of 0.
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 product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. 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 | |
Signal Processing Blockset | |
| Maximum | Signal Processing Blockset |
| Minimum | Signal Processing Blockset |
MATLAB | |
Image Processing Toolbox |
![]() | 2-D FIR Filter | 2-D IDCT | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |