Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- a, b = 1, 1
- n = 7
- r = 4
- y, x = np.ogrid[-a:n-a, -b:n-b]
- mascara = x*x + y*y <= r
- vetor = np.arange(49).reshape(n, n)
- vetor[mascara] = 255
- print(vetor)
- [[255 255 255 3 4 5 6]
- [255 255 255 255 11 12 13]
- [255 255 255 17 18 19 20]
- [ 21 255 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]]
- [[255 255 255 3 4 5 6]
- [255 8 255 10 11 12 13]
- [255 255 255 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]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement