Created
February 14, 2013 03:30
-
-
Save AdriC1705/4950405 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
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): | |
pixel[i+z,j+z]=(0,0,0) #pixel leido mas un numero random para agregar pimienta | |
else: | |
pixel[i+z,j+z] = (255,255,255) #pixel + # rand para agregar sal | |
except: | |
pass | |
img2 = img2.save('ruido.jpg') | |
timei=time() | |
timef = timei - t1 | |
print "el tiempo para agregar ruido es:"+str(timef)+"segundos" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment