dsp.Variance System object

Package: dsp

Variance of input or sequence of inputs

Description

The Variance object computes variance for an input or sequence of inputs.

To compute the variance of an input or sequence of inputs:

  1. Define and set up your variance System object™. See Construction.

  2. Call step to compute the variance according to the properties of dsp.Variance. The behavior of step is specific to each object in the toolbox.

Construction

H = dsp.Variance returns a variance System object, H, that computes the variance of an input or a sequence of inputs over the specified Dimension.

H = dsp.Variance('PropertyName',PropertyValue,...) returns a variance System object, H, with each specified property set to the specified value.

Properties

RunningVariance

Enable calculation over time

Set this property to true to enable variance calculation over successive calls to the step method. The default is false.

ResetInputPort

Enable reset input port

Set this property to true to enable reset input port. When you set the property to true, specify a reset input for the step method. The running variance resets anytime the variance object achieves the condition you specify for the ResetCondition property. This property applies when you set the RunningVariance property to true. The default is false.

ResetCondition

Reset condition for running variance mode

Specify which event resets the running variance as one of | Rising edge | Falling edge | Either edge | Non-zero |. This property applies when you set the ResetInputPort property to true.

Dimension

Dimension to operate along

Specify how the object performs the variance calculation over the data as one of | All | Row | Column | Custom |. This property applies when you set the RunningVariance property to false. The default is Column.

CustomDimension

Numerical dimension to operate along

Specify the input signal dimension (one-based value) the object uses to compute variance. The cannot exceed the number of dimensions in the input signal. This property applies when you set the Dimension property to Custom. The default is 1.

ROIProcessing

Enable region-of-interest processing

Set this property to true to enable calculating the variance within a particular region of each image. This property applies when you set the RunningVariance property to false and the Dimension property to All. The default is false. Full ROI processing support requires a Computer Vision System Toolbox™ license. With only the DSP System Toolbox™ license, Rectangles is the only selection for the ROIForm property.

ROIForm

Define the type of region of interest.

Specify the type of region of interest as one of | Rectangles | Lines | Label matrix | Binary mask |. This property applies when you set the ROIProcessing property to true. The default is Rectangle.

ROIPortion

Calculate over entire ROI or just perimeter

Specify the region over which to calculate variance as one of | Entire ROI | ROI perimeter |. This property applies when you set the ROIForm property to Rectangles. The default is Entire ROI.

ROIStatistics

Statistics for each ROI or one for all ROIs

Specify if statistics calculations are one of | Individual statistics for each ROI | Single statistic for all ROIs |. This property applies when ROIForm property is not Binary mask. The default is Individual statistics for each ROI.

ValidityOutputPort

Enable output of validity check of ROI or label numbers

Indicate whether to return the validity of the specified ROI being completely inside image when the ROIForm property is Lines or Rectangles. Indicate whether to return the validity of the specified label numbers when the ROIForm property is Label Matrix. This property applies when you set the ROIForm property to anything except Binary Mask. The default is false.

FrameBasedProcessing

Enable frame-based processing

Set this property to true to enable frame-based processing. Set this property to false to enable sample-based processing. This property applies when you set the RunningVariance property to true. The default is true.

 Fixed-Point Properties

Methods

cloneCreate variance object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset variance to zero
stepVariance of input

Examples

Compute the running variance for a signal:

 hvar = dsp.Variance;
 hvar.RunningVariance = true;
 x = randn(100,1);
 y = step(hvar, x); 
 % y(i) is the running variance of all values in the vector x(1:i)

Algorithms

This object implements the algorithm, inputs, and outputs described on the Variance block reference page. The object properties correspond to the block parameters, except:

  • Treat sample-based row input as a column block parameter is not supported by the dsp.Variance object.

  • Reset port block parameter corresponds to both the ResetCondition and the ResetInputPort object properties.

Both this object and its corresponding block let you specify whether to process inputs as individual samples or as frames of data. The object uses the FrameBasedProcessing property. The block uses the Input processing parameter. See Set the FrameBasedProcessing Property of a System object for more information.

Was this topic helpful?