[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] SDC Morphology Toolbox V1.1 15Jan02

mmhistogram - Find the histogram of the image f.


Synopsis
h = mmhistogram( f )
Input
f: Gray-scale (uint8 or uint16) or binary image (logical uint8).
Output
h: Gray-scale (uint8 or uint16) image. Histogram in a uint16 column vector.
Description
Finds the histogram of the image f and returns the result in the column vector h. For binary image the vector size is 2, for gray-scale uint8 and uint16 images, the vector size is the maximum pixel value plus one. h(1) gives the number of pixels with value 0.
Limitation
Be aware that the maximum value in the output vector is 65535. There are images where a specific gray value can appear a number larger than this value.
Examples
f=uint8([0 1 1 2 2 2 5 3 5]);
h=mmhistogram(f);
h'

ans =
     1     2     3     1     0     2
f=mmreadgray('lenina.tif');
mmshow(f);
h=mmhistogram(f);
plot(h);
image
(f)
image
(h)
Equation

equation

Algorithm
function h = mmhistogram_equ(f)
  m=max(f(:));
  h=zeros(m+1,1);
  for i=1:m+1
    h(i)=length(find(f==(i-1)));
  end
See Also
mmblob - Blob measurements from a labeled image.
mmfreedom - Control automatic data type conversion.

[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] Valid XHTML 1.0!
Copyright (c) 1998-2002 by SDC Information Systems