Skip to content

Instantly share code, notes, and snippets.

@volkanozcan2
Created January 27, 2018 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volkanozcan2/800f5eb05ec6abfee2be0cd43479585e to your computer and use it in GitHub Desktop.
Save volkanozcan2/800f5eb05ec6abfee2be0cd43479585e to your computer and use it in GitHub Desktop.
image from prime numbers
import numpy as np
import time
import primesieve
from PIL import Image
# t is time in seconds
#fps is videos frame rate
t=30
fps=30
for i in range(fps*t):
t=time.time()
p=np.array(primesieve.primes(1920*1080*i,1920*1080*(i+1)))
z=np.zeros(1920*1080*3,dtype=np.uint8)
for x in p:
z[3*(x-1920*1080*i):3*(x-1920*1080*i)+3]=[0,255,0]
z=z.reshape(1080,1920,3)
Image.fromarray(z).save("img/pr{}.png".format(i))
print("{}/{}".format(i,fps*t-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment