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 sys | |
import random | |
import math | |
archivo = open('cordenadas.dat','r') | |
lineas=archivo.readlines() | |
cordenadas = [] |
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 math import cos,sin,pi | |
from scipy.fftpack import dct,idct | |
import numpy as np | |
import random | |
from PIL import Image, ImageDraw,ImageFont | |
import os | |
#cosa = 16 | |
#suma = 0.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 regr(mat): | |
global qa | |
new = np.zeros((8,8)) | |
for i in range(8): | |
for j in range(8): | |
new[i][j] = mat[i][j]*qa[i][j] | |
c = idct(new, type=2, n=None, axis=-1, norm='ortho', overwrite_x=False) | |
for i in range(8): |
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 proces(imagen): | |
escala(imagen) ##transformamos imagen a gris | |
ancho,altura,pixels,im = cargar("gris.jpg") ##cargamos imagen a gris | |
i = 0 | |
j = 0 | |
print "valor de altura: ",altura | |
arreglo = [] | |
#for i in range(altura): | |
# arreglo.append([]) | |
# for j in range(ancho): |
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
###################dtc discrete transformer cose###################### | |
def trans(a): | |
global qa | |
b = dct(a,type=2,n=None,axis=-1,norm='ortho',overwrite_x=False) | |
#c = idct(b, type=2, n=None, axis=-1, norm='ortho', overwrite_x=False) | |
F = np.zeros((8,8)) | |
for i in range(8): | |
for j in range(8): | |
F[i][j] = b[i][j]/qa[i][j] | |
return F |
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 escala(imagen): | |
ancho,altura,pixels,im = cargar(imagen) | |
for i in range(ancho): | |
for j in range(altura): | |
(a,b,c) = pixels[i,j] | |
suma = a+b+c | |
prom = int(suma/3) | |
a = prom ##igualamos | |
b = prom ##igualamos | |
c = prom ##igualamos |
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
###################tam de la imagen################### | |
def cargar(imagen): | |
im = Image.open(imagen) | |
ancho, altura = im.size | |
pixels = im.load() | |
return ancho,altura,pixels,im | |
##################cargar imagen################# |
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 numpy as np | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
import random | |
class Baliada():##nodos principales | |
def __init__(self, posx,posy,posz,ran): | |
self.posx = posx ## pos x | |
self.posy = posy ## pos 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
import numpy as np | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
import random | |
class Baliada():##nodos principales | |
def __init__(self, posx,posy,posz,ran): | |
self.posx = posx ## pos x | |
self.posy = posy ## pos 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
if algo == 1 or bolarray[i].cond == 1: ##si algo == 1 es que encontro el nodo referencia o tiene condicion | |
pygame.draw.circle(screen, (255, 0, 255), (ax, ay), 10) ##para enviar mensajes | |
bolarray[i].cond = 1 | |
if bolarray[i].ttl <= 0: ##checa si es un nodo nuevo que acava de detectar nodo de referencia | |
ttl = ttli | |
actual = ttl | |
else: | |
ttl = bolarray[i].ttl - 1 ##modifica el ttl a pasar en caso de que sea nodo parado | |
actual = ttl | |
for j in range(len(bolarray)): ##verificar los vecinos si estan dentro del rango |
NewerOlder