Skip to content

Instantly share code, notes, and snippets.

@Visgean
Created November 24, 2016 17:24
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 Visgean/485ffd313c4059714a74e7a4c0e561ec to your computer and use it in GitHub Desktop.
Save Visgean/485ffd313c4059714a74e7a4c0e561ec to your computer and use it in GitHub Desktop.
treshold = 100
matrix = []
with open('image-brightness-values.csv') as csv_file:
for line in csv_file.readlines():
matrix.append(map(int, line.split(',')))
def process_line(line):
pairs = zip(line, line[1:])
sub = lambda (x, y): abs(x-y)
diffs = map(sub, pairs)
return [
'-' if d < treshold else '|'
for d in diffs
]
edges = map(process_line, matrix)
for l in edges:
print ' '.join(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment