4 import Image, ImageTk, ImageDraw
10 def PixelGood(pixel, threshold):
11 return (pixel[1] > (pixel[0] + pixel[2]) and pixel[1] > threshold)
15 return (e[3] - e[1]) * (e[2] - e[0])
19 for i in range(0, len(pixel)):
21 greyscale = greyscale / len(pixel)
24 def Process(threshold):
31 for x in range(0, image.size[0]):
32 for y in range(0, image.size[1]):
33 if (PixelGood(pix[x, y], threshold)):
43 test = Image.new("RGB", (xMax - xMin + 1, yMax - yMin + 1), "white")
44 draw = ImageDraw.Draw(test)
46 for x in range(xMin, xMax):
47 for y in range(yMin, yMax):
48 if (PixelGood(pix[x, y], threshold)):
49 draw.rectangle([x-xMin, y-yMin, x-xMin, y-yMin], "black")
51 draw.rectangle([x-xMin, y-yMin, x-xMin, y-yMin], "white")
54 #test.resize([test.size[0]*2, test.size[1]*2]).save(output_file)
55 test.save(output_file)
56 #os.system("convert " + str(output_file) + " -resize 40% " + str(output_file))
61 if (len(sys.argv) != 3):
62 print("Usage " + str(sys.argv[0]) + " input output")
64 input_file = sys.argv[1]
65 output_file = sys.argv[2]
67 image = Image.open(input_file)
71 # This displays all good pixels in the image; testing