-
Notifications
You must be signed in to change notification settings - Fork 3
/
img.py
25 lines (19 loc) · 607 Bytes
/
img.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
import numpy as np
from PIL import Image
file=open("img_file.txt","r")
img_f=file.readlines()
for i in range(len(img_f)):
img_f[i]=img_f[i].strip()
#img = Image.open('1.jpeg')
for i in range(len(img_f)):
img=Image.open("Images/"+img_f[i])
array = np.array(img)
print(array.shape)
file=open("Image_Detail/"+str(i)+".txt","w")
print(i)
file.write(str(len(array[0]))+"\n")
file.write(str(len(array))+"\n")
for i in range(len(array)):
for j in range(len(array[0])):
file.write(str(array[i][j][0])+","+str(array[i][j][1])+","+str(array[i][j][2])+","+str(j+1)+","+str(i+1)+"\n")
file.close()