Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- radius = 3
- x,y = np.ogrid[-3:3:5j, -3:3:5j]
- dist = ((x**2+y**2)**0.5)
- mask = dist-radius).clip(0,None)
- print(mask)
- array([[1.24264069, 0.35410197, 0. , 0.35410197, 1.24264069],
- [0.35410197, 0. , 0. , 0. , 0.35410197],
- [0. , 0. , 0. , 0. , 0. ],
- [0.35410197, 0. , 0. , 0. , 0.35410197],
- [1.24264069, 0.35410197, 0. , 0.35410197, 1.24264069]])
- mask = mask/np.max(mask)
- mask = 1 - mask
- print(mask)
- array([[0. , 0.71504074, 1. , 0.71504074, 0. ],
- [0.71504074, 1. , 1. , 1. , 0.71504074],
- [1. , 1. , 1. , 1. , 1. ],
- [0.71504074, 1. , 1. , 1. , 0.71504074],
- [0. , 0.71504074, 1. , 0.71504074, 0. ]])
Add Comment
Please, Sign In to add comment