mardi 26 septembre 2017

draw random circles using PIL in python

I'm having some problems to draw in python N numbers of circles of the same size in a XY tiff image. My progress is not to much, but I have the following code:

di = 0.25   # Diameter of circles in micrometers
d = np.round(di/0.065) # conversion to pixels
s = 512  #  Image size x
s1 = 512 #  Image size y



image = Image.new('RGB', (s, s1),'black')
TCZs = [50]

for n in TCZs:

    x = random.randint(0-d,s-d)
    y = random.randint(0-d,s-d)
    x1 = x+d
    y1 = y+d
    draw = ImageDraw.Draw(image)
    draw.ellipse((x,y,),(x1,y1), fill = 'red', outline ='red')


image.save('test.tif','tiff')

This code produce the following error:

TypeError: ellipse() got multiple values for argument 'fill'

I understand that this error is produced by my iteration, however I don't understand how to keep going with the solution. Some ideas? thanks in advance




Aucun commentaire:

Enregistrer un commentaire