Skip to content

Instantly share code, notes, and snippets.

@joschuck
Last active July 5, 2020 15:21
Show Gist options
  • Save joschuck/86c577dfd3225c7f080e36c8b6f50d6e to your computer and use it in GitHub Desktop.
Save joschuck/86c577dfd3225c7f080e36c8b6f50d6e to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
image = cv2.imread('book_page_1_cropped.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
ret, th = cv2.threshold(gray,
127, # threshold value
255, # maximum value assigned to pixel values exceeding the threshold
cv2.THRESH_BINARY) # threshold method type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment