Code covered by the BSD License  

Highlights from
Image segmentation using Otsu thresholding

5.0

5.0 | 4 ratings Rate this file 137 Downloads (last 30 days) File Size: 3.53 KB File ID: #26532
image thumbnail

Image segmentation using Otsu thresholding

by Damien Garcia

 

29 Jan 2010 (Updated 10 Mar 2010)

OTSU(I,N) segments the image I into N classes by means of Otsu's N-thresholding method.

| Watch this File

File Information
Description

IDX = OTSU(I,N) segments the image 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.
 
IDX = OTSU(I) uses two classes (N=2, default value).
 
[IDX,sep] = OTSU(I,N) also returns the value (sep) of the separability criterion within the range [0 1]. Zero is obtained only with data having less than N values, whereas one (optimal value) is obtained only with N-valued arrays.

If I is an RGB image, a Karhunen-Loeve transform is first performed on the three R,G,B channels. The segmentation is then carried out on the image component that contains most of the energy.
    
Example:
---------
    load clown
    subplot(221)
    X = ind2gray(X,map);
    imshow(X)
    title('Original','FontWeight','bold')
    for n = 2:4
      IDX = otsu(X,n);
      subplot(2,2,n)
      imagesc(IDX), axis image off
      title(['n = ' int2str(n)],'FontWeight','bold')
    end

 ------
See also:
http://www.biomecardio.com/matlab/otsu.html
-----

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
11 Mar 2010 Lukas Lansky

Works nice!

28 Apr 2010 Fu  
10 Jul 2010 Dalal

i am trying to segment the image of signature
is it possible to apply the same code ?
thank you

13 Oct 2010 Matteo Niccoli

It has worked for me very nicely. I like to run it in a while loop that breaks when sep starts decreasing.

11 Feb 2011 Samuele

works smoothly...thx ;)

21 Jan 2012 Jamuna

I am geting this error...How do I correct it?

Undefined function or method 'otsu' for input arguments of type 'uint8'.

Please login to add a comment or rating.
Updates
31 Jan 2010

New screenshot.

28 Feb 2010

RGB images are now analyzed in the gray, R, G and B scales.

04 Mar 2010

The segmentation for RGB image has been improved: a KLT is performed and we keep the component of highest energy.

10 Mar 2010

Minor modifications

Tag Activity for this File
Tag Applied By Date/Time
image processing Damien Garcia 29 Jan 2010 10:33:05
image segmentation Damien Garcia 29 Jan 2010 10:33:05
thresholding Damien Garcia 10 Mar 2010 10:45:53
image segmentation Abdelghani Djebbari 10 Mar 2010 13:25:20
image segmentation Andrzej Romanowski 14 Dec 2010 14:46:18

Contact us at files@mathworks.com