Mercurial > hg > config
annotate python/clean_whiteboard.py @ 749:f7b939206baf
PS
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 30 Jun 2015 15:22:21 -0700 |
parents | 1453c8a3747e |
children |
rev | line source |
---|---|
659
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
3 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
4 """ |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
5 From https://gist.github.com/lelandbatey/8677901 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
6 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
7 #!/bin/bash |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
8 convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
9 """ |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
10 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
11 import argparse |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
12 import os |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
13 import subprocess |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
14 import sys |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
15 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
16 __all__ = ['main'] |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
17 here = os.path.dirname(os.path.realpath(__file__)) |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
18 string = (str, unicode) |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
19 |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
20 def main(args=sys.argv[1:]): |
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
21 |
660
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
22 # parse command line |
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
23 parser = argparse.ArgumentParser(description=__doc__) |
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
24 parser.add_argument('input', |
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
25 help='input file') |
661
1453c8a3747e
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
660
diff
changeset
|
26 parser.add_argument('output', |
1453c8a3747e
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
660
diff
changeset
|
27 help='output file') |
660
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
28 options = parser.parse_args(args) |
659
e5be32fea639
https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
29 |
660
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
30 subprocess.check_call(['convert', options.input, '-morphology', 'Convolve', 'DoG:15,100,0', '-negate', '-normalize', '-blur', '0x1', '-channel', 'RBG', '-level', '60%,91%,0.1', options.output]) |
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
31 |
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
32 if __name__ == '__main__': |
f77be2334246
STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents:
659
diff
changeset
|
33 main() |