This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

vision.Histogram System object

Package: vision

Generate histogram of each input matrix


    Note:   The vision.Histogram System object will be removed in a future release. Use the imhist function with equivalent functionality instead.

The Histogram object generates histogram of each input matrix.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


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 (MATLAB Coder).
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


resetReset histogram bin values to zero
stepReturn histogram for input data
Common to All System Objects

Create System object with same property values


Expected number of inputs to a System object


Expected number of outputs of a System object


Check locked states of a System object (logical)


Allow System object property value changes


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.

Introduced in R2012a

Was this topic helpful?