This script finds the edges of an image provided. First, it converts it into grayscale, and then looks for a difference in color. The tolerance is the difference. It saves both the grayscale image and the final one.
from PIL import Image #im = Image.open("Lenna_(test_image).png").convert("L") # tolerance = 16 for best results # lower the tolerance, more lines pass threw. tolerance = 15 im = Image.open("honestwork.png").convert("L") pix = im.load() print (im.size) im.save('greyscale.png') for x in range(0, im.size[0]-1): for y in range(0, im.size[1]-1): if abs(pix[x,y+1] - pix[x,y])>tolerance or abs(pix[x+1,y] - pix[x,y])>tolerance: pix[x,y] = 0 else: pix[x,y] = 255 im.save('findEdges.png')