With a position x,y as 30,40 as the top left corner of a 30 by 30 pixels (900 pixels total) grid I want to create an array with these x,y points using numpy. I've tried with a list and for loop but it seems slow I hope numpy will be faster.
Asked
Active
Viewed 782 times
1 Answers
1
source: Numpy matrix of coordinates
Something like this?
import numpy as np
rows = np.arange(30,60)
cols = np.arange(40,70)
coords = np.empty((len(rows), len(cols), 2), dtype=np.intp)
coords[..., 0] = rows[:, None]
coords[..., 1] = cols

Anton vBR
- 18,287
- 5
- 40
- 46
-
Not really this, it should return an array like [[30,40],[31,40],[32,40],...,[90,110]] – Samuel M. Aug 13 '17 at 08:53
-
@SamuelMuiruri That creates a bigger matrix than you originally asked for or am I missing smh? – Anton vBR Aug 13 '17 at 13:03