-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitting.py
More file actions
40 lines (34 loc) · 1.03 KB
/
splitting.py
File metadata and controls
40 lines (34 loc) · 1.03 KB
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
import numpy as np
import cv2
from PIL import Image
from PIL import ImageMath
import PIL.ImageOps
def column_average(column):
return np.average(column)
def column_search(column):
if column_average(column) < 240:
return True
return False
def f_number_snip(img):
sep = []
img_detec = 0
for column in range(len(img)):
column_added = 0
if (column_added == 0):
if (img_detec == 1):
if (column_search(img[column])):
print(column_average(img[column]))
sep.append(img[column])
column_added +=1
else:
return sep
img_detec == 0
elif (img_detec == 0 and column_search(img[column])):
sep.append(img[column])
column_added +=1
img_detec +=1
if __name__ == "__main__":
image = Image.open("5_2.JPG")
image = PIL.ImageOps.invert(image)
res = np.asarray(image, dtype="uint8")
print(res[])