-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhistogrameq.py
56 lines (56 loc) · 2.47 KB
/
histogrameq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import numpy as np
import cv2 as cv
import time
from matplotlib import pyplot as plt
time.sleep(0.7)
print("Have you moved the data in output directory '/home/shaik/output' to another location to avoid data loss?")
time.sleep(0.7)
print("if yes then type y else n")
val = input("(y or n):")
if val == 'y' or val == 'Y':
in_img = input("Enter fingerprint image location(exact location):")
img = cv.imread(in_img,0)
plt.imshow(img, cmap='gray')
plt.title("Fingerprint before equalisation")
plt.savefig('/home/shaik/output/img_before_eq.jpg')
equ = cv.equalizeHist(img)
plt.imshow(img,cmap = 'gray')
plt.title("Fingerprint after equalization")
plt.savefig('/home/shaik/output/img_after_eq.jpg')
result = np.hstack((img,equ))
plt.imshow(result, cmap='gray')
plt.title("Fingerprints before and after histogram equalization")
plt.savefig('/home/shaik/output/img_before_after_eq.jpg')
plt.show()
plt.hist(img.ravel(),256,[0,256])
plt.title("histogram of Fingerprint before equalization")
plt.savefig('/home/shaik/output/hist_before_eq.jpg')
plt.show()
plt.hist(equ.ravel(),256,[0,256])
plt.title("histogram of Fingerprint after equalization")
plt.savefig('/home/shaik/output/hist_after_eq.jpg')
plt.show()
print("Histogram processing done successfully\n")
print("fingerprint image before equalization done is stored at /home/shaik/output/img_before_eq.jpg")
time.sleep(0.1)
print("fingerprint image after equalization done is stored at /home/shaik/output/img_after_eq.jpg")
time.sleep(0.1)
print("fingerprint image before and after histogram equalization is stored at /home/shaik/output/img_before_after_eq.jpg")
time.sleep(0.1)
print("histogram image of fingerprint before equalization is stored at /home/shaik/output/hist_before_eq.jpg")
time.sleep(0.1)
print("histogram image of fingerprint before equalization is stored at /home/shaik/output/hist_before_eq.jpg")
time.sleep(0.7)
print("All the processed and unprocessed Fingerprints and histograms are saved to")
time.sleep(0.7)
print("/home/shaik/output directory")
time.sleep(0.7)
print("kindly move them to other directory to avoild data loss before performing equalization for other Fingerprint\n")
elif val=='n' or val == 'N':
print("if we use histogram equivalization for this fingerprint without moving the data in output directory, we may loose the processed histograms of previous fingerprints")
time.sleep(0.7)
print("Move the data in output directory and try again!!\n")
quit()
else:
print("bad response, try again!!")
quit()