Last active
December 12, 2015 06:28
-
-
Save robertovalenzuela91/4728920 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 pygame | |
from pygame.locals import * | |
import Image | |
pygame.init() | |
pantalla = pygame.display.set_mode((190,250)) | |
# FOTO NORMAL | |
imagen = pygame.image.load("imagen.jpg") | |
#FOTO ESCALA DE GRISES | |
image = Image.open("imagen.jpg") | |
pixeles = image.load() | |
ancho, altura =image.size | |
for x in range(ancho): | |
for y in range(altura): | |
(r,g,b) = image.getpixel((x,y)) | |
promedio=((r+g+b)/3) | |
pixeles[x,y] = (promedio,promedio,promedio) | |
image.show() | |
#FOTO Invertida | |
image = Image.open("imagen.jpg") | |
pixeles = image.load() | |
ancho, altura =image.size | |
for x in range(ancho): | |
for y in range(altura): | |
(r,g,b) = image.getpixel((x,y)) | |
if (r>0 and g>0 and b>0): | |
r=255-r | |
g=255-g | |
b=255-b | |
pixeles[x,y] = (r,g,b) | |
image.show() | |
#FOTO binarizada con un umbral | |
image = Image.open("imagen.jpg") | |
pixeles = image.load() | |
ancho, altura =image.size | |
for x in range(ancho): | |
for y in range(altura): | |
(r,g,b) = image.getpixel((x,y)) | |
if (r<128 and g<128 and b<128): | |
r=0 | |
g=0 | |
b=0 | |
if (r>128 and g>128 and b>128): | |
r=255 | |
g=255 | |
b=255 | |
pixeles[x,y] = (r,g,b) | |
image.show() | |
#FOTO Escala de grises con binarizacion | |
image = Image.open("imagen.jpg") | |
pixeles = image.load() | |
ancho, altura =image.size | |
promedio=((r+g+b)/3) | |
for x in range(ancho): | |
for y in range(altura): | |
(r,g,b) = image.getpixel((x,y)) | |
if (promedio<=128 and promedio<=128 and promedio<=128): | |
r=0 | |
g=0 | |
b=0 | |
else: | |
r=255 | |
g=255 | |
b=255 | |
pixeles[x,y] = (r,g,b) | |
image.show() | |
#FOTO binarizada con dos UMBRALes | |
image = Image.open("imagen.jpg") | |
pixeles = image.load() | |
ancho, altura =image.size | |
for x in range(ancho): | |
for y in range(altura): | |
(r,g,b) = image.getpixel((x,y)) | |
promedio = (r+g+b/3) | |
if promedio <= 100: | |
r=0 | |
g=0 | |
b=0 | |
if promedio >= 220: | |
r=255 | |
g=255 | |
b=255 | |
pixeles[x,y] = (promedio,promedio,promedio) | |
image.show() | |
#FOTO PLATEADAS | |
image = Image.open("imagen.jpg") | |
pixeles = image.load() | |
ancho, altura =image.size | |
for x in range(ancho): | |
for y in range(altura): | |
(r,g,b) = image.getpixel((x,y)) | |
promedio =((r-80)+(g-80)+(b-80)/3) | |
pixeles[x,y] = (promedio,promedio,promedio) | |
image.show() | |
while True: | |
for eventos in pygame.event.get(): | |
if eventos.type == pygame.QUIT: | |
exit() | |
pantalla.blit(imagen,(0,0)) | |
pygame.display.update() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment