-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom line.py
More file actions
53 lines (45 loc) · 1.11 KB
/
random line.py
File metadata and controls
53 lines (45 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 7 09:27:27 2017
@author: USER
"""
from skimage.draw import line
import numpy as np
from numpy.random import randint
import matplotlib.pyplot as plt
img = np.zeros((500,500), dtype=np.uint8)
for k in range(10):
r = randint(0,499 , size=1)[0]
c = randint(0,499 , size=1)[0]
a = randint(0,499 , size=1)[0]
b = randint(0,499 , size=1)[0]
if c<b:
d = randint(c,b , size=1)[0]
else :
d = randint(b,c , size=1)[0]
if r<a:
e = randint(r,a , size=1)[0]
else :
e = randint(a,r , size=1)[0]
tree = line(r,c,e,d)
tree2 = line(e,d,a,b)
img[tree] = 1
img[tree2] = 1
r = randint(0,499 , size=1)[0]
c = randint(0,499 , size=1)[0]
a = randint(0,499 , size=1)[0]
b = randint(0,499 , size=1)[0]
if c<b:
d = randint(c,b , size=1)[0]
else :
d = randint(b,c , size=1)[0]
if r<a:
e = randint(r,a , size=1)[0]
else :
e = randint(a,r , size=1)[0]
tree = line(r,c,e,d)
tree2 = line(e,d,a,b)
img[tree] = 1
img[tree2] = 1
plt.imshow(img)
plt.show()