Skip to content

Instantly share code, notes, and snippets.

@vane90
Last active December 13, 2015 22:18
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 vane90/4983297 to your computer and use it in GitHub Desktop.
Save vane90/4983297 to your computer and use it in GitHub Desktop.
import sys,pygame
import Image
from math import*
from time import*
import math
def main():
pygame.init()
screen = pygame.display.set_mode((300,300))
imagen1 = binariza ()
imagen = pygame.image.load(foto1)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.blit(imagen,(0,0))
pygame.display.update()
def binariza():
image1 = Image.open("conv.png")
imagen1 = image1.load()
x1,y1 = image1.size
minimo = 80
for i in range(x1):
for j in range(y1):
a1 = imagen1[i,j]
rgb = (a1[0] + a1[1] + a1[2])/3
if rgb < minimo:
imagen1[i,j] = (0,0,0)
else:
imagen1[i,j] = (255,255,255)
new = 'binariza2.jpg'
image1.save(new)
return new
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment