Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import numpy as np
  2.  
  3. a, b = 1, 1
  4. n = 7
  5. r = 4
  6.  
  7. y, x = np.ogrid[-a:n-a, -b:n-b]
  8. mascara = x*x + y*y <= r
  9.  
  10. vetor = np.arange(49).reshape(n, n)
  11. vetor[mascara] = 255
  12.  
  13. print(vetor)
  14.  
  15. [[255 255 255 3 4 5 6]
  16. [255 255 255 255 11 12 13]
  17. [255 255 255 17 18 19 20]
  18. [ 21 255 23 24 25 26 27]
  19. [ 28 29 30 31 32 33 34]
  20. [ 35 36 37 38 39 40 41]
  21. [ 42 43 44 45 46 47 48]]
  22.  
  23. [[255 255 255 3 4 5 6]
  24. [255 8 255 10 11 12 13]
  25. [255 255 255 17 18 19 20]
  26. [ 21 22 23 24 25 26 27]
  27. [ 28 29 30 31 32 33 34]
  28. [ 35 36 37 38 39 40 41]
  29. [ 42 43 44 45 46 47 48]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement