Imshow x and y transposed?

It appears to me that when imshow tells you that the mouse cursor is at
x=50, y=100

That corresponds to array element
im[100, 50]

Is there a reason imshow does not have x be the first coordinate of the array as I would think of as conventional usage?

Tom

It appears to me that when imshow tells you that the mouse cursor is at
x=50, y=100

That corresponds to array element
im[100, 50]

Is there a reason imshow does not have x be the first coordinate of the
array as I would think of as conventional usage?

That is not conventional usage. Instead, for images, it common for the image to correspond to a printout of memory, using the C convention. Hence the column index is X, and incrementing the row index yields the next line down on the page, thereby corresponding to a decrease in the Y coordinate.

Eric

···

On 03/15/2011 10:23 AM, Tom Dimiduk wrote:

Tom

Ah thanks. I am used to the general math/physics convention of x axis being first. Caught between conventions I guess. Good to know why things are done differently.

I am using the mouse click event.xdata and event.ydata as indexes into an array. From what you say, it looks like I want to use
im[im.shape[1]-y, x] to get the pixel a user clicked on. Is that correct?

Thanks agaian,
Tom

···

On 03/15/2011 05:35 PM, Eric Firing wrote:

On 03/15/2011 10:23 AM, Tom Dimiduk wrote:

It appears to me that when imshow tells you that the mouse cursor is at
x=50, y=100

That corresponds to array element
im[100, 50]

Is there a reason imshow does not have x be the first coordinate of the
array as I would think of as conventional usage?

That is not conventional usage. Instead, for images, it common for the
image to correspond to a printout of memory, using the C convention.
Hence the column index is X, and incrementing the row index yields the
next line down on the page, thereby corresponding to a decrease in the Y
coordinate.

Eric

Tom

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Ah thanks. I am used to the general math/physics convention of x axis
being first. Caught between conventions I guess. Good to know why
things are done differently.

I am using the mouse click event.xdata and event.ydata as indexes into
an array. From what you say, it looks like I want to use
im[im.shape[1]-y, x] to get the pixel a user clicked on. Is that correct?

Almost--but mpl is using an inverted Y-axis so that the y-coordinate increases downward. Therefore you need only im[round(y), round(x)].

Eric

···

On 03/15/2011 11:47 AM, Tom Dimiduk wrote:

Thanks agaian,
Tom

On 03/15/2011 05:35 PM, Eric Firing wrote:

On 03/15/2011 10:23 AM, Tom Dimiduk wrote:

It appears to me that when imshow tells you that the mouse cursor is at
x=50, y=100

That corresponds to array element
im[100, 50]

Is there a reason imshow does not have x be the first coordinate of the
array as I would think of as conventional usage?

That is not conventional usage. Instead, for images, it common for the
image to correspond to a printout of memory, using the C convention.
Hence the column index is X, and incrementing the row index yields the
next line down on the page, thereby corresponding to a decrease in the Y
coordinate.

Eric

Tom

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users