Main Content

Image Statistics

Calculate mean, variance, and standard deviation

  • Image Statistics block

Libraries:
Vision HDL Toolbox / Statistics

Description

The Image Statistics block calculates the mean, variance, and standard deviation of streaming video data. Each calculation is performed over all pixels in the input region of interest (ROI). The block implements the calculations by using hardware-efficient algorithms.

Ports

This block uses a streaming pixel interface with a bus for frame control signals. This interface enables the block to operate independently of image size and format. The pixel input port supports single pixel streaming or multipixel streaming. Single pixel streaming accepts a single pixel value each clock cycle. Multipixel streaming accepts a vector of M pixels per clock cycle to support high-frame-rate or high-resolution formats. The M value corresponds to the Number of pixels parameter of the Frame To Pixels block. Along with the pixel, the block accepts a pixelcontrol bus that contains five control signals. The control signals indicate the validity of each pixel and their location in the frame. For multipixel streaming, one set of control signals applies to all pixels in the vector. To convert a frame (pixel matrix) into a serial pixel stream and control signals, use the Frame To Pixels block. For a full description of the interface, see Streaming Pixel Interface.

Input

expand all

For single pixel streaming, specify pixel as an unsigned scalar value that represents grayscale intensity. For multipixel streaming, specify pixel as a column vector of Number of pixels pixel intensity values. Number of pixels can be two, four, or eight.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: uint8 | uint16 | fixdt(0,W,0) | double | single

The pixelcontrol bus contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

For multipixel streaming, each vector of pixel values has one set of control signals. Because the vector has only one valid signal, the pixels in the vector must be either all valid or all invalid. The hStart and vStart signals apply to the pixel with the lowest index in the vector. The hEnd and vEnd signals apply to the pixel with the highest index in the vector.

Data Types: bus

Output

expand all

The block uses full-precision arithmetic for internal calculation. At the output ports, intermediate data is cast back to the input type by using the following fixed-point settings: Rounding method = Nearest, and Overflow action = Saturate. The table shows the output word length for each calculation, relative to the input word length (IWL).

Mean VarianceStd. Deviation
IWLIWLIWL

Mean of the most recent input frame completed, returned as a scalar. The data type of mean is same as the data type of pixel.

Data Types: uint8 | uint16 | fixdt(0,W,0) | double | single

Variance of the most recent input frame completed, returned as a scalar. The data type of var is same as the data type of pixel.

Data Types: uint8 | uint16 | fixdt(0,W,0) | double | single

Standard deviation of the most recent input frame completed, returned as a scalar. The data type of stdDev is same as the data type of pixel.

Data Types: uint8 | uint16 | fixdt(0,W,0) | double | single

The block sets this output to true when the statistic outputs for a frame are ready.

Data Types: Boolean

Parameters

expand all

Select this parameter to enable the mean port and calculate the mean of each input frame.

Select this parameter to enable the var port and calculate the variance of each input frame.

Select this parameter to enable the stdDev port and calculate the standard deviation of each input frame.

Tips

  • To change the size and dimensions of the ROI, you can manipulate the input video stream control signals. See Regions of Interest.

  • The number of valid pixels in the input image affects the accuracy of the mean approximation. To avoid approximation error, use an image that contains a multiple of 64n pixels, up to 64n+1 pixels, where n equals 0, 1, 2, or 3. For details of the mean approximation, see Algorithm.

  • The block calculates statistics over frames up to 644 (16, 777, 216) pixels in size. This size supports HD frames.

Algorithms

expand all

Extended Capabilities

Version History

Introduced in R2015a

expand all

See Also

(Computer Vision Toolbox) | (Computer Vision Toolbox) | (Computer Vision Toolbox) | |