Matlab functions    from  Biom├ęCardio    

 
   orthofit
polycenter   

otsu

Image segmentation using Otsu's thresholding

Contents

Download

otsu.m

Syntax

   IDX = otsu(I)
   IDX = otsu(I,N)
   [IDX,sep] = otsu(...)

Description

IDX = otsu(I,N) segments the array I into N classes by means of Otsu's N-thresholding method. otsu returns an array IDX containing the cluster indices (from 1 to N) of each point. Zero values are assigned to non-finite (NaN or Inf) pixels.

IDX = otsu(I) uses N = 2 (default value).

[IDX,sep] = otsu(...) also returns the value (sep) of the separability criterion within the range [0 1]. Zero is obtained only with arrays having less than N values, whereas one (optimal value) is obtained only with N-valued data.

Notes:

Examples

Read the image "clown" from Matlab and segment the picture in 2, 3 and 4 classes.

load clown

Convert the indexed image to intensity (grayscale) image:

imshow(X,map)
X = ind2rgb(X,map);

Segment the gray-level image into 2, 3 or 4 classes by using the Otsu's method:

for n = 2:4
    IDX = otsu(X,n);
    figure, imagesc(IDX), axis image off
    title(['n = ' int2str(n)])
end
colormap(gray)

Reference & Information

Otsu N., A threshold selection method from gray-level histogram, IEEE Trans. Syst. Man Cybern. 9:62-66;1979

Otsu's method on Wikipedia.

See also

graythresh

About the author

Damien Garcia, Eng., Ph.D.
Assistant professor, Department of radiology
CRCHUM, University of Montreal Hospital
Montreal, QC, Canada
Damien.Garcia.REMOVE-THIS@BiomeCardio.com

www.biomecardio.com