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.

1

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Not really this, it should return an array like [[30,40],[31,40],[32,40],...,[90,110]]
@SamuelMuiruri That creates a bigger matrix than you originally asked for or am I missing smh?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.