Skip to content

Instantly share code, notes, and snippets.

@miau
Created May 12, 2014 16:08
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 miau/ef3fdc496b17da4df2da to your computer and use it in GitHub Desktop.
Save miau/ef3fdc496b17da4df2da to your computer and use it in GitHub Desktop.
Scripts to research ScanSnap/fi7160
import Image
import glob
import os.path
for infile in glob.glob("*.jpg"):
file, ext = os.path.splitext(infile)
im = Image.open(infile)
pixels = im.load()
(w, h) = im.size
for y in range(h):
for x in range(w):
(r, g, b) = pixels[x, y]
a = min([r, g, b]) + 1
z = max([r, g, b]) + 1
if 1.0 * z / a < 1.2:
pixels[x, y] = (0, 0, 0)
im.save(file + ".png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment