# script Distribution-fromImage.py ''' generate 2d random numbers distributed according to brightness of an image .. author:: Guenter Quast ''' import numpy as np import matplotlib.pyplot as plt from PIL import Image #open an image img=Image.open('image.jpg') #img.show() print("image size loaded:", img.size[0], img.size[1]) pix=img.load() def rand_fromImage(size=1): # generate pairs of random numbers from an image def r_fromImage(maxtrials=10000): # helper function: generate 2 random numbers from an image # probability to select (r1,r2)depends on brightness of a pixel cnt=0 while cntr+b+g): return rx,ry # end helper function cnt=0 x=[] y=[] while cnt