Skip to content

Instantly share code, notes, and snippets.

@rbrito
Forked from bazub/gist:3877971
Created July 7, 2020 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbrito/8e17e6bbc93bc2999d92b979d080c9c3 to your computer and use it in GitHub Desktop.
Save rbrito/8e17e6bbc93bc2999d92b979d080c9c3 to your computer and use it in GitHub Desktop.
Grayscale/Binary images using PIL
im=Image.open("1.jpg")
#im=im.rotate(1)
im.save("e.jpg")
im2=im.convert("L")
im2.save("b.jpg")
threshold = 100
im = im2.point(lambda p: p > threshold and 255)
im.save("d.jpg")
img="d.jpg"
result = tesseract.ProcessPagesWrapper(img,api)
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment