Last active
December 13, 2015 22:18
-
-
Save vane90/4983297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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