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.
Thanks for sharing!
Thank you so much!
All your set of adaptive thresholding scripts is amazing.
Great work. It's very appreciated.
great, thanks a lot dear jan Motl.
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.
not working proper
what are different parameters of bernsen
Extended help text.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.