-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.py
More file actions
43 lines (31 loc) · 660 Bytes
/
a.py
File metadata and controls
43 lines (31 loc) · 660 Bytes
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
import cv2
import numpy as np
from matplotlib import pyplot as plt
#from matplotlib import pyplot as plt
img =cv2.imread("ph.jpg",0)
#cv2.imshow("Testing",img)
#cv2.waitKey(1000)
row=img.shape[0]
col=img.shape[1]
top=row*col
f=[]
b=[]
for i in range(0,256):
f.append(0)
b.append(i)
for i in range(0,row):
for j in range(0,col):
f[img[i,j]]=f[img[i,j]]+1
for i in range(0,256):
f[i]=f[i]/top
plt.plot(b,f)
plt.show()
#for i in range(0,256):
# print("f[",i,"] = ",f[i])
for i in range(0,row):
for j in range(0,col):
if img[i,j]<90:
img[i,j]=0
else:
img[i,j]=255
cv2.imwrite("img5.png",img)