import cv2
import numpy as np

img  = cv2.imread('bookpage.jpg')
grayscaled = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

retval, grayscaled_threshold = cv2.threshold(grayscaled, 12, 255, cv2.THRESH_BINARY)

cv2.imshow('grayscaled threshold',grayscaled_threshold)
cv2.waitKey(0)
cv2.destroyAllWindows()
