+ return new_image
+
+def half_centers(image):
+ image_l = image.load()
+ new_image = Image.new('L', image.size)
+ new_image_l = new_image.load()
+
+ x_s = 0
+ y_s = 0
+ n = 0
+ for x in range(0, image.size[0] / 2):
+ for y in range(0, image.size[1]):
+ if image_l[x, y] > 127:
+ x_s += x
+ y_s += y
+ n += 1
+ new_image_l[x_s / n, y_s / n] = 255
+
+ x_s = 0
+ y_s = 0
+ n = 0
+ for x in range(image.size[0] / 2, image.size[0]):
+ for y in range(0, image.size[1]):
+ if image_l[x, y] > 127:
+ x_s += x
+ y_s += y
+ n += 1
+ new_image_l[x_s / n, y_s / n] = 255
+
+ return new_image
+