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
  • 1
  • 12

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
  • 16,833
  • 3
  • 36
  • 44