Skip to content

Instantly share code, notes, and snippets.

@joschuck
Last active July 9, 2020 17:52
Show Gist options
  • Save joschuck/33e0353c5fc3c4fd12c90aad424f9656 to your computer and use it in GitHub Desktop.
Save joschuck/33e0353c5fc3c4fd12c90aad424f9656 to your computer and use it in GitHub Desktop.
Enhance Scanned Document
image = cv2.imread('input.jpg', 0) # read as grayscale
th = cv2.adaptiveThreshold(image,
255, # maximum value assigned to pixel values exceeding the threshold
cv2.ADAPTIVE_THRESH_GAUSSIAN_C, # gaussian weighted sum of neighborhood
cv2.THRESH_BINARY, # thresholding type
5, # block size (5x5 window)
3) # constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment