Table of Contents

Class Average

Namespace
Bonsai.Dsp
Assembly
Bonsai.Dsp.dll

Represents an operator that calculates the average, or arithmetic mean, of each channel for all the arrays in the sequence.

[Combinator]
[WorkflowElementCategory(ElementCategory.Transform)]
public class Average
Inheritance
Average
Inherited Members

Methods

Process<TArray>(IObservable<TArray>)

Calculates the average, or arithmetic mean, of each channel for all the arrays in an observable sequence.

public IObservable<Scalar> Process<TArray>(IObservable<TArray> source) where TArray : Arr

Parameters

source IObservable<TArray>

A sequence of array values for which to calculate the per-channel average.

Returns

IObservable<Scalar>

A Scalar tuple containing the average of each channel for all the arrays in the source sequence.

Type Parameters

TArray

The type of the array-like objects in the source sequence.

Remarks

For multi-channel images using BGR, RGB, or other color formats, the order of values in the Scalar tuple follows the order of channels in the color format, e.g. for a BGR image, the average for the blue-channel will be stored in Val0, the average for the green-channel in Val1, etc.

For single-channel arrays such as a grayscale image or a 2D floating point array with signal processing data, the average will be stored in the first value of the tuple, Val0.

Process<TArray, TMask>(IObservable<Tuple<TArray, TMask>>)

Calculates the average, or arithmetic mean, of each channel for all the arrays in an observable sequence, where each array is paired with a mask where non-zero values indicate which elements in the array should be averaged.

public IObservable<Scalar> Process<TArray, TMask>(IObservable<Tuple<TArray, TMask>> source) where TArray : Arr where TMask : Arr

Parameters

source IObservable<Tuple<TArray, TMask>>

A sequence of array pairs, where the first array contains the elements used to compute the average, and the second array contains the operation mask, where non-zero values indicate which elements in the first array should be averaged.

Returns

IObservable<Scalar>

A Scalar tuple containing the average of each channel for all the arrays in the source sequence.

Type Parameters

TArray

The type of the array-like objects to average.

TMask

The type of the array-like objects used as an operation mask.