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 Image #esto para trabajar con imagenes | |
import sys | |
import pygame | |
#cargamos y abrimos imagen | |
def imagen(): | |
img = Image.open("dori.jpg") | |
ancho,alto = img.size | |
img = eg(img,ancho,alto) | |
return img, ancho, alto |
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 Image #esto para trabajar con imagenes | |
import sys | |
import pygame | |
#definimos minimos y maximos para los umbrales | |
minimo = 100 | |
maximo = 200 |
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
def conv(img,ancho,alto): | |
tiemp = time() | |
pixels =img.load() | |
matrizX =([-1,0,1],[-2,0,2],[-1,0,1]) | |
matrizY =([1,2,1],[0,0,0],[-1,-2,-1]) | |
for i in range(ancho): | |
for j in range(alto): | |
sumx = 0 | |
sumy = 0 |
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
def filtro(img,ancho,alto): | |
tiemp= time() | |
pixel =img.load() | |
for i in range (ancho): | |
for j in range(alto): | |
c = 0 | |
prom = 0.0 | |
try: | |
if(pixel[i+1,j]): | |
prom += pixel[i+1,j][0] |
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 Image #esto para trabajar con imagenes | |
import sys | |
import pygame | |
import math | |
from time import * | |
#definimos | |
minimo = 100 | |
maximo = 200 |
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
def ruido(img2, ancho,alto): | |
t1 = time() | |
pixel= img2.load() | |
for i in range(ancho): | |
for j in range(alto): | |
(r,g,b)= img2.getpixel((i,j)) #obtener pixeles | |
ruido = random.randint(0,255) #generar ruido random | |
z = random.randint(0,5000) | |
try: | |
if (ruido < 100): |
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
def byeruido(img2,ancho,alto): | |
pixel = img2.load() | |
t2=time() | |
for i in range(ancho): | |
for j in range(alto): | |
(r,g,b)=img2.getpixel((i,j)) | |
try: | |
if(pixel[i,j]==(0,0,0) or pixel[i,j]==(255,255,255)): | |
#print pixel[i,j] | |
#print "ya pase por aki" |
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
def formas(img,ancho,alto): | |
pixel= img.load() | |
cntdr = [] | |
colors=[] | |
for i in range(ancho): | |
for j in range(alto): | |
if pixel[i,j]== (0,0,0): | |
a=random.randint(0,255) | |
b=random.randint(0,255) | |
c=random.randint(0,255) |
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
try: | |
#c1 =centro 1 y c2 = centro 2 | |
cm.append((sum(c1)/float(len(c1)),sum(c2)/float(len(c2)))) | |
except: | |
pass | |
draw=ImageDraw.Draw(img) | |
for i,Z in enumerate(cm): | |
draw.ellipse((Z[0]-2,Z[1]-2,Z[0]+2,Z[1]+2),fill=(0,0,0)) | |
img =img.save('cm.jpg') |
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 | |
import random | |
import string | |
from time import * | |
def k_m_p(word,text): | |
x=0 #inicio de la lista | |
print 'cadena: %s'%(word) | |
print 'texto: %s\n' %(text) |
OlderNewer