I am experimenting with local (adaptive) grey threshold for the binarization of B&W photographs of yellowed manuscripts:

Raw image

I got adaptive thresholding working in both scikit-image and cv2. In both cases (grey < threshold_niblack() in scikit-image and cv.adaptiveThreshold() in cv2 -- all Python) the result I get is successfully binarized, with the background pretty much uniform -- and completely full of noise:

Binarized image

What kind of step do I now need to separate the text from this background noise?

  • 2
    $\begingroup$ looks like you should be able to extract features by area. So remove any continious area smaller than x pixels $\endgroup$
    – joojaa
    Commented Nov 8, 2019 at 17:10
  • 1
    $\begingroup$ +1 to joojaa's comment, but you really shouldn't have got here in the first place -- any adaptive thresholding method should provide a bias parameter that will help you avoid amplifying low-amplitude noise in nearly uniform regions. $\endgroup$
    – user106
    Commented Nov 8, 2019 at 19:13
  • $\begingroup$ @Rahul I see, thank you. Adjusting the "Constant subtracted from the mean" does help. $\endgroup$ Commented Nov 9, 2019 at 6:18
  • $\begingroup$ @joojaa Thank you! I found out how to find, filter, and draw contours. This is promising. $\endgroup$ Commented Nov 9, 2019 at 6:19

1 Answer 1


Besides the suggestions in comments, I would suggest a high pass filtering to get rid of the low frequency noise, before running your local thresholding. Here an example with GIMP, that you can probably easily reproduce with opencv as well.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.