Newbie question: Dealing with images and imshow

Hi,

sorry for all the newbie questions. I have looked though the documentation

but have not found anything on how to handle the fact that matplotlib takes

the array indices as the lower left corner position for the value, while an image

has its pixel values at the center of the pixel. Is there anything written on how

to handle this?

Cheers

Tommy

tgrav@…935…

http://homepage.mac.com/tgrav/

"Any intelligent fool can make things bigger,

more complex, and more violent. It takes a

touch of genius – and a lot of courage –

to move in the opposite direction"

– Albert Einstein

I don't understand what you're asking here. Is there some unexpected interpolation going on? A small example might be useful to clarify if noone else steps forward with an answer.

Gary R.

Tommy Grav wrote:

···

Hi,

   sorry for all the newbie questions. I have looked though the documentation but have not found anything on how to handle the fact that matplotlib takes the array indices as the lower left corner position for the value, while an image
has its pixel values at the center of the pixel. Is there anything written on how to handle this?

Cheers

Tommy

As I understand it, you are having an issue with the alignment of pixels
and axis tickmarks.

Perhaps the following will help you to set up a workaround (check the
'0.5' values?)
http://sourceforge.net/mailarchive/message.php?msg_id=15509515

Maybe that helps.

Cheers
JP

Tommy Grav wrote:

···

Hi,

   sorry for all the newbie questions. I have looked though the
documentation
but have not found anything on how to handle the fact that matplotlib
takes
the array indices as the lower left corner position for the value,
while an image
has its pixel values at the center of the pixel. Is there anything
written on how
to handle this?

Cheers

Tommy

tgrav@...935... <mailto:tgrav@…935…>

http://homepage.mac.com/tgrav/

"Any intelligent fool can make things bigger,
more complex, and more violent. It takes a
touch of genius -- and a lot of courage --
to move in the opposite direction"
                         -- Albert Einstein

Just looking back through the thread, I guess the problem is that the coords returned by JH's example don't correspond to the centre of the pixel. I'm pretty sure you'll have to do the transformation yourself using values from the axes and figure classes.

Gary R.

Gary Ruben wrote:

···

I don't understand what you're asking here. Is there some unexpected interpolation going on? A small example might be useful to clarify if noone else steps forward with an answer.

Gary R.

Tommy Grav wrote:

Hi,

   sorry for all the newbie questions. I have looked though the documentation but have not found anything on how to handle the fact that matplotlib takes the array indices as the lower left corner position for the value, while an image
has its pixel values at the center of the pixel. Is there anything written on how to handle this?

Cheers

Tommy

Wouldn’t it be simpler to use the extent key to shift the image?

Let x and y be the pixel centers

imshow(M, extent = [x[0]-dx, x[-1]-dx, y[0]-dy, y[-1]-dy])
where dx and dy is half the distance between pixels.

David

2006/5/2, Gary Ruben <gruben@…636…>:

···

Just looking back through the thread, I guess the problem is that the
coords returned by JH’s example don’t correspond to the centre of the
pixel. I’m pretty sure you’ll have to do the transformation yourself
using values from the axes and figure classes.

Gary R.

Gary Ruben wrote:

I don’t understand what you’re asking here. Is there some unexpected
interpolation going on? A small example might be useful to clarify if
noone else steps forward with an answer.

Gary R.

Tommy Grav wrote:

Hi,

sorry for all the newbie questions. I have looked though the
documentation but have not found anything on how to handle the fact

that matplotlib takes the array indices as the lower left corner
position for the value, while an image
has its pixel values at the center of the pixel. Is there anything
written on how to handle this?

Cheers

Tommy


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier

Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users