Document scanning and Optical Character Recognition (OCR) are some of the oldest problems in the field of computer vision. In this article we’re going to focus on how to create an easy to read version of a poor quality book page image. This example will outline the differences between image thresholding methods covered in this article.

Simple Thresholding

Image for post

Binary thresholding in action!

Also known as global thresholding, simple thresholding has a very straight-forward approach: the same threshold value is applied for every pixel. If the pixel value is smaller than the threshold, it is set to 0, otherwise it is set to a maximum value. OpenCV’s threshold method expects four arguments:

  1. a grayscale version of your image
  2. the threshold value
  3. the maximum value assigned, if the input pixel exceeds the threshold (255 for white)
  4. the thresholding type (see documentation of example code on Github)

#otsu #adaptive-thresholding #python #computer-vision #opencv

Enhance a Document Scan using Python and OpenCV
24.60 GEEK