Skip to content
Snippets Groups Projects
Commit 694ae353 authored by Dorababu A's avatar Dorababu A
Browse files

Enhance fp image

parent 8922ac63
No related branches found
No related tags found
No related merge requests found
import numpy as np
import serial
import time
from PIL import Image
import matplotlib.pyplot as plt
import fingerprint_enhancer
from skimage.morphology import skeletonize
# remove dot function for thinning fp image
def removedot(invertThin):
temp0 = np.array(invertThin[:])
temp0 = np.array(temp0)
temp1 = temp0/255
temp2 = np.array(temp1)
temp3 = np.array(temp2)
enhanced_img = np.array(temp0)
filter0 = np.zeros((10,10))
W,H = temp0.shape[:2]
filtersize = 6
for i in range(W - filtersize):
for j in range(H - filtersize):
filter0 = temp1[i:i + filtersize,j:j + filtersize]
flag = 0
if sum(filter0[:,0]) == 0:
flag +=1
if sum(filter0[:,filtersize - 1]) == 0:
flag +=1
if sum(filter0[0,:]) == 0:
flag +=1
if sum(filter0[filtersize - 1,:]) == 0:
flag +=1
if flag > 3:
temp2[i:i + filtersize, j:j + filtersize] = np.zeros((filtersize, filtersize))
return temp2
# create a temp list to store values
......@@ -28,7 +61,7 @@ while samples<4:
# num = int(string)
# print(num, end = ' ')
temps[samples].append(int(string))
temps[samples].append(0)
ser.close()
# print(temps)
......@@ -36,25 +69,21 @@ while samples<4:
# Store list into numpy array
fp_array = np.array(temps[samples])
# print(fp_array)
print( type(fp_array))
print(len(fp_array))
# Construct image from data
w,h = 240, 240
t=(h,w,3)
fp_sample=np.zeros(t, dtype=np.uint8)
for index,value in enumerate(fp_array):
a = int( index % 160 )
b = int( index / 160 )
fp_sample[a,b] = [40+a, 80+b, int(value)]
# construct image from data
fp_image = np.reshape(fp_array, (160,160))
# enhance fp image
fp_enhance_image = fingerprint_enhancer.enhance_Fingerprint(fp_image)
# thinning enhaced image
fp_enhance_image[fp_enhance_image == 255] =1
skeleton = skeletonize(fp_enhance_image)
skeleton = np.array(skeleton, dtype=np.uint8)
skeleton = removedot(skeleton)
i = Image.fromarray(fp_sample)
i.show()
plt.imshow(skeleton, 'gray')
plt.show()
samples += 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment