Skip to content

Instantly share code, notes, and snippets.

@DanBrink91
Created August 25, 2013 02:13
Show Gist options
  • Save DanBrink91/6331537 to your computer and use it in GitHub Desktop.
Save DanBrink91/6331537 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
import Image
source = Image.open("less3.png")
img = source.load()
width = source.size[0]
height = source.size[1]
def total_color_difference(pixel, other_pixel):
return abs(pixel[0] - other_pixel[0]) + abs(pixel[1] - other_pixel[1]) + abs(pixel[2] - other_pixel[2])
DIFFERENCE_THRESHOLD = 175 # mess with this until it looks nice.
# find vertical edges
for y in xrange(1, height-1):
for x in xrange(0, width):
if total_color_difference(img[x,y-1], img[x,y+1]) >= DIFFERENCE_THRESHOLD:
img[x, y] = (255, 119, 255)
source.save("edges.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment