No BSD License  

Highlights from
Local Adaptive Thresholding

4.55

4.5 | 20 ratings Rate this file 253 Downloads (last 30 days) File Size: 144 KB File ID: #8647
image thumbnail

Local Adaptive Thresholding

by

 

05 Oct 2005 (Updated )

Threshold with local statistics, such as mean or median.

| Watch this File

File Information
Description

ADAPTIVETHRESHOLD An adaptive thresholding algorithm that seperates the foreground from the background with nonuniform illumination.
  bw=adaptivethreshold(IM,ws,C) outputs a binary image bw with the local threshold mean-C or median-C to the image IM.

ws is the local window size.

tm is 0 or 1, a switch between mean and median. tm=0 mean(default); tm=1 median.

Contributed by Guanglei Xiong (xgl99@mails.tsinghua.edu.cn) at Tsinghua University, Beijing, China.

For more information, please see
  http://homepages.inf.ed.ac.uk/rbf/HIPR2/adpthrsh.htm

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (30)
03 Jul 2014 2one

For others, it appears that C (=constant) was originally the binary image segmentation threshold.

I have modified my version of the code as follows:

replace:

sIM=mIM-IM-C;
bw=im2bw(sIM,0);

with:

sIM=mIM-IM;
thresh=graythresh(sIM);
bw=im2bw(sIM,thresh);

This now uses the adaptive (mean) filter to highlight image features (i.e. mIM-IM) and then the Otsu threshold to segment and generate a binary image.

03 Jul 2014 2one

this works quite well for my application but can anyone explain to me what the algorithm is doing exactly?
I understand that the algorithm generates a local mean filtered image by iterating over each pixel for user window size but what is line:

sIM=mIM-IM-C

this subtracts the original image and a constant, C, from the local mean filtered image. What is C and why do this?

28 Mar 2013 Kang Zheng

What is C exactly?

27 Dec 2011 Hokchhay Tann

Great code, but not applicable to my type of images. I'm trying to make the threshold automated since I have a hundred thousands of this kind. I appreciate any suggestions.

https://sites.google.com/site/hokchhay10/

27 Sep 2011 Shashi

I did apply this algorithm on my images but it didn't work out completely. There is a research paper by Q.Huang et.al. which speaks about Otsu's thresholding using adaptive window. I would like to know if somebody has implemented that.

14 Aug 2011 Rosidah Lazid

Had anyone here used this code for processing trabecular micro CT images? Appreciate your feedback on the outcome. Thanks.

11 Aug 2011 eray

Very simple and effective, thanks!

04 Aug 2011 Nek Valous

Great script!

31 May 2011 Ana Triana

Easy to read and use. Thank you.

13 May 2011 Jorge Lewinnek

what is that window size?

27 Apr 2011 Martin  
21 Jan 2011 Navneet Viswan

is it possible to detect laser traces on an object using this algorithm?

01 Dec 2009 Hans Müller

@Sanjay

How about sharing it, then?

05 Sep 2009 sanjay bhattacharya

it can detect the letters even where its very dark (see the lines in the end) line 8 etc

05 Sep 2009 sanjay bhattacharya

I have written a code without using any std functions like imfilter etc, its purely based on fundamentals.

CHECK OUT THE OUTPUT IMAGES
http://sites.google.com/site/adapthresh/

05 Sep 2009 sanjay bhattacharya

Nice code, but not applicable in extreme situations.

21 Jul 2008 hafid rafi

it's very very simple thanks

29 Apr 2008 Guillermo Moreno

Simple and Fast, thanks

10 Apr 2008 alev soke

thank you very much.
it is a perfect program.

01 Apr 2008 zhang shi jie

really nice

24 Mar 2008 ranjeeth dasineni

works great man!!

09 Oct 2007 kayalvizhi lakshmanan  
19 Sep 2007 saravanan radhakrishnan

really good code

30 Jul 2007 mel tem

thank you

24 Jun 2007 amit vishnipolsky  
06 Mar 2007 saravanan kumar

nice work

31 Jan 2007 Piyorot Khongchuay

cool

26 Apr 2006 Alan Zhang

The 2 lines near the end should be changed from:
sIM=mIM-IM;
bw=im2bw(sIM,C);
to:
sIM=mIM-IM-C;
bw=im2bw(sIM,0);
This change allows C to be +ve and negative. In the old code bw=im2bw(sIM,C) causes error when C is -ve.

22 Mar 2006 tester Mc tester

it didnt work!!
i get
Error using ==> mat2gray
A must be double

07 Nov 2005 J. Zhou

Pretty cool results with flexible options.
Great job!

Updates
07 Oct 2005

remove unnecessary Thumbs.db in zip file

Contact us