File Exchange

image thumbnail

Sauvola local image thresholding

version (6.33 KB) by Jan Motl
Sauvola binarization method is well suited for ill illuminated or stained documents.


Updated 08 May 2013

View Version History

View License

The implemented Sauvola method uses integral images for fast computation of the threshold function.

The Sauvola method is described in:

J. Sauvola and M. Pietikainen, Adaptive document image binarization, Pattern Recognition 33, 2000. -

The modification which uses integral images providing a 20-fold speedup (according to the paper) is described in this paper:

F. Shafait, D. Keysers, and T. M. Breuel, Efficient implementation of local adaptive thresholding techniques using integral images, Document Recognition and Retrieval XV, 2008 -

A paper evaluating binarization methods:

P. Stathis, E. Kavallieratou and N. Papamarkos - An Evaluation Technique for Binarization Algorithms, Journal of Universal Computer Science, 2008, -

Cite As

Jan Motl (2021). Sauvola local image thresholding (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Jorge Rivé

Thank you for sharing this.
I get totally white image (I can send you the image, but don't know how to append it to this)....what could be going wrong?


A question, ... why the output does not change by changing the neighborhood or thresholding?

Jan Motl

@mohamed abu eita: I tested the code in MATLAB 2015a on OS X 10.11 and it still works.

Jan Motl

@Sara: ImageJ uses a circular local window, instead of a rectangular one. See:


Good Work

wahyudi setiawan

Peyman Obeidy

Thank you for this, nicely done.

Divakar Badal


Thank you so much!
It helps me a lot!

Tu Nguyen Anh


Thank you so much!
All your set of adaptive thresholding scripts is amazing.
Great work. It's very appreciated.

mohamed abu eita

Hi i want to run this code on matlab 2015 but not run


I have ImageJ software which has a adaptive thresholding tools and sauvola's method, But I didnt get the same results!

can anyone please tell me why the results is different??


I do appreciated you for what you have done, your codes are great, thanks a lot and again.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!