vision.Histogram System object

Package: vision

Generate histogram of each input matrix


The Histogram object generates histogram of each input matrix.


H = vision.Histogram returns a histogram System object, H, that computes the frequency distribution of the elements in each input matrix.

H = vision.Histogram(Name,Value,) returns a histogram object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

H = vision.Histogram(MIN,MAX,NUMBINS,Name,Value,...) returns a histogram System object, H, with the LowerLimit property set to MIN, UpperLimit property set to MAX, NumBins property set to NUMBINS and other specified properties set to the specified values.

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation.
Code Generation Support, Usage Notes, and Limitations.



Lower boundary

Specify the lower boundary of the lowest-valued bin as a real-valued scalar value. NaN and Inf are not valid values for this property. The default is 0. This property is tunable.


Upper boundary

Specify the upper boundary of the highest-valued bin as a real-valued scalar value. NaN and Inf are not valid values for this property. The default is 1. This property is tunable.


Number of bins in the histogram

Specify the number of bins in the histogram. The default is 256.


Enable output vector normalization

Specify whether the output vector, v, is normalized such that sum(v) = 1. Use of this property is not supported for fixed-point signals. The default is false.


Enable calculation over successive calls to step method

Set this property to true to enable computing the histogram of the input elements over successive calls to the step method. Set this property to false to enable basic histogram operation. The default is false.


Enable resetting in running histogram mode

Set this property to true to enable resetting the running histogram. When the property is set to true, a reset input must be specified to the step method to reset the running histogram. This property applies when you set the RunningHistogram property to true. When you set this property to false, the object does not reset. The default is false.


Condition for running histogram mode

Specify event to reset the running histogram as Rising edge, Falling edge, Either edge, or Non-zero. This property applies when you set the ResetInputPort property to true. The default is Non-zero.

 Fixed-Point Properties


cloneCreate 2-D histogram object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
resetReset histogram bin values to zero
stepReturn histogram for input data


Compute histogram of a grayscale image.

 img = im2single(rgb2gray(imread('peppers.png')));
 hhist2d = vision.Histogram;
 y = step(hhist2d,img);
 bar((0:255)/256, y);


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

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

  • The Find Dimensions Over block parameter with Entire input or Each column options, does not have a corresponding property. The object finds dimensions over the entire input.

Was this topic helpful?