File Exchange

image thumbnail

Bernsen local image thresholding

version 1.1 (258 KB) by

Implementation of Bernsen's thresholding method.

4.16667
6 Ratings

9 Downloads

Updated

View License

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.

Comments and Ratings (7)

baicai

baicai (view profile)

nice!

Thanks for sharing!

Gabor

Gabor (view profile)

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

sara

sara (view profile)

great, thanks a lot dear jan Motl.

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:
http://fiji.sc/wiki/index.php/Auto_Local_Threshold#Bernsen

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.

Rohan Ghare

not working proper
what are different parameters of bernsen

thong

thong (view profile)

Updates

1.1

Extended help text.

MATLAB Release
MATLAB 6.5 (R13)

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

» Watch video