SIVP Toolbox
Last update : April, 2006

imhist - get the histogram of an image

### Calling Sequence

  `[counts, cells] = imhist(im)`
  `[counts, cells] = imhist(im, bins)`
  `[counts, cells] = imhist(im, bins [,width [,color]])`

### Parameters

- `im`: An image, which can be a boolean, `uint8`, `int8`, `uint16`, `int16`, `int32` or `double` image.
- `bins`: The number of bins of the histogram. If `bins` is not specified, the function will used default value which determined by the image type: 2 for boolen, 2^8 for uint8 and int8, 2^16 for uint16 and int16, 2^16 for int32 (2^32 will need huge computer memory), and 10 for double.
- `width`: This argument will be sent to `bar` function. It is a real scalar, defines the width (a percentage of the available room) for the bar (default: 0.8, i.e 80%).
- `color`: This argument will be sent to `bar` function. It is a string (default: 'blue'), specifing the inside color bar.
- `counts`: the returned histogram.
- `cells`: the intervals for bins.

### Description

`imhist` return the histogram of an image. If more than 2 arguments are give, the histogram will be shown in a figure.

If `step` is the step of scalar `cells` (`cells(i+1)=cells(i)+step`), the i'th bin is half-open interval `(cells(i)-step/2, cells(i)+step/2]` for `i > 1`, and `[cells(1)-step/2, cells(1)+step/2]` for `i=1`.

If more than 2 arguments are given, the function will call `bar(cells, counts, ...)` and send rest arguments to `bar` function to display the histogram.

### Supported image type

BOOLEAN, UINT8, INT8, UINT16, INT16, INT32, DOUBLE.

### Examples

        im = imread('lena.png');
        im = rgb2gray(im);
        [count, cells]=imhist(im);
        [count, cells]=imhist(im, 10);
        scf(0); imhist(im, 10, '');
        scf(1); imhist(im, 10, 0.5);
        scf(2); imhist(im, 10, 'green');
        scf(3); imhist(im, 10, 0.8, 'green');

### Authors

  Shiqi Yu <shiqi.yu[at]gmail.com>

### Availability

The latest version of SIVP can be found at

http://sivp.sourceforge.net

### See Also

`mean2`, `corr2`,