Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: e246f9172d
Fetching contributors…

Cannot retrieve contributors at this time

executable file 23 lines (17 sloc) 0.613 kb
#!/usr/bin/env python
import sys
import argparse
import Image
import getfile
parser = argparse.ArgumentParser()
parser.add_argument('images', metavar='N', type=str, nargs='*',
help='images (default:lena)',
default=[getfile.get_from_strawlab("week1/lena-color.png")])
parser.add_argument('-t', '--threshold', type=int, default=80)
args = parser.parse_args()
for fn in args.images:
print "Thresholding %s at %d" % (fn, args.threshold)
im = Image.open(fn)
im = im.convert('L')
thr = im.point(lambda x: (x > args.threshold)*255)
thr.save("binary_"+fn)
Jump to Line
Something went wrong with that request. Please try again.