annotate python/clean_whiteboard.py @ 660:f77be2334246

STUB: python/clean_whiteboard.py
author Jeff Hammel <k0scist@gmail.com>
date Thu, 03 Apr 2014 16:41:21 -0700
parents e5be32fea639
children 1453c8a3747e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 type=argparse.FileType('r'),
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
26 help='input file')
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
27 parser.add_argument('-o', '--output' dest='output',
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
28 type=argparse.FileType('w'), default=sys.stdout,
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
29 help='output file or stdout')
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
30 options = parser.parse_args(args)
659
e5be32fea639 https://gist.github.com/lelandbatey/8677901
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31
660
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
32 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
33
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
34 if __name__ == '__main__':
f77be2334246 STUB: python/clean_whiteboard.py
Jeff Hammel <k0scist@gmail.com>
parents: 659
diff changeset
35 main()