Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.