-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathigrid_example.py
46 lines (37 loc) · 940 Bytes
/
igrid_example.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
import cv2
import numpy as np
from disputils import Igrid
# boolean if True save to file else display
saveToFile=False
img = cv2.imread('jemma.png')
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#img = img[100:300,100:312]
print("shape of image {}".format(img.shape))
# dim specified the stacking width = height as the grid is a square
dim1=2
dim2=3
# create the grid object
ig=Igrid(dim1,dim2)
# stuff each cell with an image
for i in range(dim1):
for j in range(dim2):
ig.set(i,j,img)
if saveToFile:
# save to file
ig.save('firstgrid.png')
else:
# else show on screen
ig.show()
input("Hit <enter> to continue...")
ig.close()
# display without the image but only grids
ig1=Igrid(dim1,dim2)
for i in range(dim1):
for j in range(dim2):
ig1.set(i,j,img,draw=False)
if saveToFile:
ig1.save("secondgrid.png")
else:
ig1.show()
input("Hit <enter> to continue...")
ig1.close()