Commit 77af0150 authored by Gihan Jayatilaka's avatar Gihan Jayatilaka

codebook

parent 0662e1a9
import sys
import numpy as np
print("python generate-patterns.py 10000 100 100 fileName.npy")
print("python generate-patterns.py [1] [2] [3] [4] ")
NO_FRAMES=int(sys.argv[1])
GRID_HEIGHT=int(sys.argv[2])
GRID_WIDTH=int(sys.argv[3])
SAVE_FILE_NPY=sys.argv[4]
ar=np.random.randint(low=0,high=2,size=(NO_FRAMES,GRID_HEIGHT,GRID_WIDTH),dtype=np.uint8)
for f in range(NO_FRAMES):
for r in range(0,GRID_HEIGHT-1,1):
for c in range(0,GRID_WIDTH-1,1):
print(ar[f,r:r+2,c:c+2])
while np.sum(ar[f,r:r+2,c:c+2])==4 or np.sum(ar[f,r:r+2,c:c+2])==0:
ar[f,r:r+2,c:c+2]=np.random.randint(low=0,high=2,size=(2,2),dtype=np.uint8)
np.save(SAVE_FILE_NPY,ar)
# print(ar[:10,:10,:10])
print("Saved variable ar of size {} to file {}".format(ar.shape,SAVE_FILE_NPY))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment