Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Niblack algorithm for Document binarization

i've this photo :

enter image description here

and i'm trying to make Document binarization using niblack algorithm i've implemented the simple Niblack algorithm

T = mean + K* standardDiviation

and that was it's result:

enter image description here

the problem is there's some parts of the image in which the window doesn't contain any objects so it detects the noise as objects and elaborates them .

i tried to apply blurring filter then global thresholding that was the result :

enter image description here

which wont be solved by any other filter i guess the only solution is preventing the algorithm from detecting global noise if the window i free from object

i'm interested to do this using niblack algorithm not using other algorithm so any suggestions ?

like image 907
Hady Elsahar Avatar asked Apr 18 '12 09:04

Hady Elsahar


2 Answers

Did you look here: https://stackoverflow.com/a/9891678/105037

local_mean = imfilter(X, filt, 'symmetric');
local_std = sqrt(imfilter(X .^ 2, filt, 'symmetric'));
X_bin = X >= (local_mean + k_threshold * local_std);

I don't see many options here if you insist to use niblack. You can change the size and type of the filter, and the threshold.

BTW, it seems that your original image has colors. This information can significantly improve black text detection.

like image 85
Serg Avatar answered Sep 23 '22 00:09

Serg


There are range of methods that can help in this situation:

  1. Of course, you can change algorithm it self =)
  2. Also it is possible just apply morphology filters: first you apply maximum in the window, and after - minimum. You should tune windows size to achieve a better result, see wiki.
  3. You can choose the hardest but the better way and try to improve Niblack's scheme. It is necessary to increase Niblack's windows size if standard deviation is smaller than some fixed number (should be tuned).
like image 22
Egor Ershov Avatar answered Sep 24 '22 00:09

Egor Ershov