0% encontró este documento útil (0 votos)
90 vistas4 páginas

Procesamiento de Imágenes en Python

Este documento presenta un informe académico de la Facultad de Ingeniería de la Escuela Profesional de Ingeniería de Sistemas. El informe titulado "Tarea 04" fue realizado por seis autores y asesorado por Jorge Isaac Necochea Chamorro.

Cargado por

carlos quispe
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como DOCX, PDF, TXT o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
90 vistas4 páginas

Procesamiento de Imágenes en Python

Este documento presenta un informe académico de la Facultad de Ingeniería de la Escuela Profesional de Ingeniería de Sistemas. El informe titulado "Tarea 04" fue realizado por seis autores y asesorado por Jorge Isaac Necochea Chamorro.

Cargado por

carlos quispe
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como DOCX, PDF, TXT o lee en línea desde Scribd

FACULTAD DE INGENIERIA

ESCUELA PROFESIONAL DE INGENIERIA DE SISTEMAS

INFORME ACADEMICO

“Titulo”

“Tarea 04 “

Autor(es):

Azpilcueta Mendoza, Carlos


Marcatinco Pariona, Jean Pierre
Naupan Falcon Jose Alonso
Baltodano Quispe Carlos Javier
Holssen Jeffershon Maza Barrena
Gonzales Guillermo Julio Cesar

Asesor:

Jorge Isaac Necochea Chamorro

LIMA – PERÚ

2021
CODIGO
FUNCIONES
#BINARIZACION
from PIL import Image

umbral1=int(input("Ingrese el numero de umbral"))

def binarizacion(img, umbral):


arr = img.load()
for x in range(img.size[0]):
for y in range(img.size[1]):
p = img.getpixel((x,y))
if p > umbral:
arr[x,y] = 255
else:
arr[x,y] = 0
img = Image.open('C:\\Users\\Beto\\Desktop\\huella.jpg').convert("L")

binarizacion(img,umbral1)
#grabamos
img.save('C:\\Users\\Beto\\Desktop\\huella22.jpg')
#mostramos la nueva imagen
#img.show()

#ADELGAZA

def adelgazamiento(img):
arr = img.load()
for x in range(1,img.size[0]-1,1):
for y in range(1,img.size[1]-1,1):
la = img.getpixel((x-1,y-1))
lb = img.getpixel((x-1,y))
lc = img.getpixel((x-1,y+1))
ld = img.getpixel((x,y-1))
le= img.getpixel((x,y))
lf = img.getpixel((x,y+1))
lg = img.getpixel((x+1,y-1))
lh = img.getpixel((x+1,y))
li = img.getpixel((x+1,y+1))
if le == 0:
if ((la+ld+lg)== 255*3 and (lc+lf+li)==0):
arr[x,y] = 255
elif ((la+lb+lc)==0 and (lg+lh+li)==255*3):
arr[x,y] = 255
elif ((la + ld + lg) == 0 and (lc + lf + li) == 255 * 3):
arr[x, y] = 255
elif ((la + lb + lc) == 255*3 and (lg + lh + li) == 0):
arr[x, y] = 255
elif ((ld + lg + lh) == 255*3 and (lb + le + lf) == 255 *
3):
arr[x, y] = 255
elif ((lf + li + lh) == 255*3 and (lb + le + ld) == 0):
arr[x, y] = 255
elif ((lb + lc + lf) == 255*3 and (ld + le + lh) == 0):
arr[x, y] = 255
elif ((lb + la + ld) == 255*3 and (lf + le + lh) == 0):
arr[x, y] = 255
img =
Image.open('C:\\Users\\Beto\\Desktop\\huella22.jpg').convert("L")
adelgazamiento(img)
#grabamos
img.save('C:\\Users\\Beto\\Desktop\\huella23.jpg')
# #mostramos la nueva imagen
#img.show()

def Minucias(img):
ter = 0
bif = 0
# Ciclo para hacer el recorrido de 3 en 3 tanto horizontal como
vertical
for x in range(1, img.size[0] - 1, 3):
for y in range(1, img.size[1] - 1, 3):
# Se captura el valor de cada pixel y se transforma en el
valor 1 si tenían un valor de 255
# Esto porque el algoritmo para encontrar el CN es binario
la = img.getpixel((x - 1, y + 1))
if la == 255:
la = 1
lb = img.getpixel((x - 1, y))
if lb == 255:
lb = 1
lc = img.getpixel((x - 1, y - 1))
if lc == 255:
lc = 1
ld = img.getpixel((x, y + 1))
if ld == 255:
ld = 1
le = img.getpixel((x, y))
if le == 255:
le = 1
lf = img.getpixel((x, y - 1))
if lf == 255:
lf = 1
lg = img.getpixel((x + 1, y + 1))
if lg == 255:
lg = 1
lh = img.getpixel((x + 1, y))
if lh == 255:
lh = 1
li = img.getpixel((x + 1, y - 1))
if li == 255:
li = 1

# Formula/Algoritmo
CN = 0.5*((ld-la)**2 + (lg-ld)**2 + (lh-lg)**2 + (li-
lh)**2 + (lf-li)**2 + (lc-lf)**2 + (lb-lc)**2 + (la-lb)**2)

if CN == 3 or CN == 1: # Si el valor de CN es 3 o 1, se
cuentan las terminaciones
ter += 1
else: # Sino se cuentan las bifurcaciones
bif += 1
# Al final se imprime el total de terminaciones y bifurcaciones
print("Terminacioes: "+str(ter)+"\nBifurcaciones: "+str(bif))
img =
Image.open('C:\\Users\\Beto\\Desktop\\huella23.jpg').convert("L")
Minucias(img)
img.show()
PRUEBA

También podría gustarte