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 diferencia(img1,img2): | |
ancho,alto = foto.size | |
ancho,alto = foto2.size | |
foto3 = Image.new("RGB",(ancho1,alto1)) | |
pix = foto.load() | |
pixel = foto2.load() | |
pixeles = foto3.load() | |
for i in range(alto-1): | |
for j in range(ancho-1): | |
diferen = abs(pixeles[i,j][0] - pixeles2[i,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
#---------------------------------------------# | |
def dif_esq(img,img2,ancho,alto): | |
pic = Image.open('eg.png') | |
pix = pic.load() | |
pix2 = img2.load() | |
for i in range(ancho): | |
for j in range(alto): | |
(r,g,b)=img.getpixel((i,j)) | |
(r,g,b) = img2.getpixel((i,j)) | |
nw = pix2[i,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
#----------------------------------------------------# | |
def filtro_esquinas(img,ancho,alto): | |
#pic = Image.open('eg.jpg') | |
pixeles = img.load() | |
for i in range(ancho): | |
for j in range(alto): | |
l = [] | |
(r,g,b) = img.getpixel((i,j)) | |
try: | |
if (pixeles[i+1,j]): #derecha |
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 frecuentes(histo, cantidad): | |
frec = list() | |
for valor in histo: | |
if valor is None: | |
continue | |
frecuencia = histo[valor] | |
acepta = False | |
if len(frec) <= cantidad: | |
acepta = True | |
if not acepta: |
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 bfs(img,ancho,alto,color,posa): | |
pixel= img.load() | |
cont=0 | |
cen1=[] | |
cen2=[] | |
cola=[] #creamos la cola | |
puntos = [] | |
cola.append(posa) #posicion actual se agrega a la cola | |
bla = posa | |
inicio = pixel[posa] |
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
set title "HISTOGRAMA" | |
st grid | |
plot "hzt.dat", "vert.dat" | |
pause mouse | |
reset |
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 horizontalh(image): | |
h = list() | |
im = image.load() | |
fl = open('hzt.dat','w') | |
#prom = 0 | |
for x in range(image.size[0]): | |
suma= 0 | |
for y in range(image.size[1]): | |
suma += im[x,y] | |
fl.write(str(x)+' '+str(suma)+'\n') |
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
#histograma del lado horizontal | |
def horizontalh(image): | |
h = list() | |
im = image.load() | |
fl = open('hzt.dat','w') | |
#prom = 0 | |
for x in range(image.size[0]): | |
suma= 0 | |
for y in range(image.size[1]): | |
suma += im[x,y] |
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
from time import * | |
import sys | |
import Tkinter | |
from PIL import Image, ImageTk | |
import random | |
import math | |
from math import * | |
def img(): | |
image = Image.open("conv.png") |
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 | |
def contar(cadena): | |
letras = dict() | |
for l in cadena: #l = letras en cadena | |
if l in letras: | |
letras[l] +=1 | |
else: | |
letras[l] = 1 | |
print letras |