0

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.

Samuel M.
  • 127
  • 2
  • 14
  • I think this answer has a solution for you: https://stackoverflow.com/a/32208565/5207081 – dusk Aug 12 '17 at 08:05

1 Answers1

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