Document toolboxDocument toolbox

(8.D.1.2) Histogram

Overview

Histogram of data

Discussion

The histogram module builds a histogram of the incoming data. A histogram is a graphical representation showing a visual impression of the distribution of data values. A histogram is essentially a table in which each entry represents the number of times that the input sample values fell in a particular range.

numBins specifies the total number of bins in the histogram. lowerBinCenter specifies the center of the first bin and binSpacing is the width of the bin. The center of the kth bin is:

lowerBinCenter + k*binSpacing.

The range of first bin is

[lowerBinCenter - binSpacing/2 lowerBinCenter + binSpacing/2)

If lower and upper represents the edges of a bin, then a value is counted as being in the bin if

lower <= value < upper.

Values which are less than the lower edge of the first bin are not placed into the histogram. numUnderSamples indicates how many sample values are less than the lower edge of first bin. Value which are equal or more than the upper edge of the last bin are also not placed into the histogram. numOverSamples indicates how many sample values are equal or more than the upper edge of last bin. The module has the parameter "reset" to reset the histogram. Set this to 1 to reset the histogram and set all counts to zero. The histogram is stored in the internal array hist. If OUTPUTVALUE is 1, then the array hist is output on a pin.

Type Definition

typedef struct _ModuleHistogram { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure INT32 numBins; // Number of bins in the histogram FLOAT32 lowerBinCenter; // Specifies the center of the first (lowest) bin in the histogram FLOAT32 binSpacing; // Specifies the spacing between bins INT32 reset; // Boolean parameter to reset the histogram. INT32 numHistSamples; // Number of input samples processed. INT32 numUnderSamples; // Total number of input samples that were outside of the histogram range on the low end. INT32 numOverSamples; // Total number of input samples that were outside of the histogram range on the high end. INT32* hist; // Histogram array. } ModuleHistogramClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

numBins

int

const

0

32

Unrestricted

 

lowerBinCenter

float

parameter

0

-1

-100:100

 

binSpacing

float

parameter

0

0.05

0.01:100

 

reset

int

parameter

0

0

0:1

 

numHistSamples

int

state

0

0

Unrestricted

 

numUnderSamples

int

state

0

0

Unrestricted

 

numOverSamples

int

state

0

0

Unrestricted

 

hist

int*

state

0

[32 x 1]

Unrestricted

 

Pins

Input Pins

Name: in

Description: Audio input

Data type: float

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: histogram value output

Data type: int

MATLAB Usage

File Name: histogram_module.m

M=histogram_module(NAME, NUMBINS, OUTPUTVALUE) Builds a histogram of incoming data on a sample-by-sample basis. The histogram is stored in an internal array and can also be optionally output on a pin. Arguments: NAME - name of the module NUMBINS - number of bins in the histogram (default = 32) OUTPUTVALUE - Boolean value which specifies whether the module has an output pin. If OUTPUTVALUE=0 (the default), then the module has no output pin. If OUTPUTVALUE=1, then the module ouputs the histogram array.

Â