On the indexing order in (numpy) arrays

Terry Reedy tjreedy at udel.edu
Thu Oct 9 22:59:00 CEST 2008


Almar Klein wrote:
> Hi,
> 
> I was wondering...
> 
> Say we have a np.ndarray A of two dimensions (a grayscale image for 
> example). If we want to access x:2, y:3, we have to do A[3,2]. Why is 
> the order of x and y reversed?

Because images are stored by rows, not by columns.  So column 3, row 2, 
is row 2, column 3.  The same convention is used for matrix coordinates.
Numpy has no idea what names you apply to the dimensions.




More information about the Python-list mailing list