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
    Nov 8 '19 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
    Nov 8 '19 at 19:13
  • $\begingroup$ @Rahul I see, thank you. Adjusting the "Constant subtracted from the mean" does help. $\endgroup$ Nov 9 '19 at 6:18
  • $\begingroup$ @joojaa Thank you! I found out how to find, filter, and draw contours. This is promising. $\endgroup$ Nov 9 '19 at 6:19

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, privacy policy and cookie policy

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