Last active
December 16, 2015 09:39
-
-
Save alice-rdz/5414319 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 c_colorear(self): | |
| im=self.boton_convolucion() | |
| #self.im2=self.boton_convolucion() | |
| pixels=im.load() | |
| porcentajes=[] | |
| fondos=[] | |
| centro_masa=[] | |
| masa=[] | |
| ancho,alto=im.size | |
| t_pixels=ancho*alto | |
| c=0 | |
| pintar=[] | |
| f=0 | |
| for i in range(ancho): | |
| for j in range(alto): | |
| pix = pixels[i,j] | |
| r,g,b= random.randint(0,255),random.randint(0,255), random.randint(0,255) | |
| fondo=(r,g,b) | |
| if (pix==(0,0,0)): | |
| c +=1 | |
| origen=(i,j) | |
| num_pixels,abscisa,ordenada,puntos=self.bfs(pix,origen,im,fondo) | |
| p=(num_pixels/float(t_pixels))*100 | |
| if p>.10: | |
| centro=(sum(abscisa)/float(num_pixels),sum(ordenada)/float(num_pixels)) | |
| #centro_masa.append(centro) | |
| masa.append(num_pixels) | |
| v=self.detectar_elipse(num_pixels,im,centro,puntos,fondo) | |
| if v==True: | |
| porcentajes.append(p) | |
| pintar.append(puntos) | |
| # self.pintar(puntos) | |
| fondos.append(fondo) | |
| centro_masa.append(centro) | |
| f +=1 | |
| # print num_pixels | |
| # centro_masa.append((sum(abscisa)/float(num_pixels),sum(ordenada)/float(num_pixels))) | |
| # print centro_masa | |
| # raw_input() | |
| #self.detectar_elipse(masa,im,centro_masa,puntos,fondo) | |
| #self.colocar_gris(im,porcentajes,fondos) | |
| oi=self.pintar(pintar) | |
| self.centro_masa(oi,centro_masa) | |
| self.imprimir_porcentajes(porcentajes) | |
| # print 'c',c | |
| # print 'termino' | |
| im.save('final.jpg') | |
| return oi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment