View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Bernsen local image thresholding

4.0 | 5 ratings Rate this file 21 Downloads (last 30 days) File Size: 258 KB File ID: #40856 Version: 1.1
image thumbnail

Bernsen local image thresholding


Jan Motl (view profile)


18 Mar 2013 (Updated )

Implementation of Bernsen's thresholding method.

| Watch this File

File Information

The method uses a user-provided contrast threshold. If the local contrast (max-min) is above or equal to the contrast threshold, the threshold is set at the local midgrey value (the mean of the minimum and maximum grey values in the local window). If the local contrast is below the contrast threshold the neighbourhood is considered to consist only of one class and the pixel is set to object or background depending on the value of the midgrey.

MATLAB release MATLAB 6.5 (R13)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
19 Jan 2017 Max Fedorchuck

Thanks for sharing!

14 Jul 2016 Gabor

Gabor (view profile)

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

15 Jan 2015 sara

sara (view profile)

great, thanks a lot dear jan Motl.

24 Oct 2014 Jan Motl

Jan Motl (view profile)

I have retested Bersen thresholding on several operating systems and versions of MATLAB. In all configurations it worked.

But keep in mind that only 2-dimensinal matrices in uint8 are supported. However, if you load a jpg file with imread command then you get a 3-dimensional uint8 matrix (even if the image is grayscale). Hence you have reduce dimensionality.

Also, it is generally advisable to test several sizes of the neighborhood to get good results.

For example, to get the illustration image from the attached jpg, use following command:
imshow(bernsen(rgb2gray(imread('image.jpg')), [93, 93]));

The description of the algorithm (and the parameters) is for example at:

If you are still having difficulties with the code, let me know more details (like version of MATALB, OS, example image, the minimal code reproducing the error,...) and I will do my best to help you.

Comment only
23 Oct 2014 Rohan Ghare

not working proper
what are different parameters of bernsen

24 Jun 2013 thong

thong (view profile)

24 Oct 2014 1.1

Extended help text.

Contact us