The image was rotated when opened with imageItem

1,766 views
Skip to first unread message

honestappl...@gmail.com

unread,
Mar 5, 2014, 7:36:40 PM3/5/14
to pyqt...@googlegroups.com
Hi, I am newbie to pyqtgraph.I opened the image file with scipy.misc.imread which stored the image data into numpy array and then attached the numpy array to the imageItem. Then, I found that the image was displayed with 90 degree rotation counter-clockwise. If I used the matplotlib.imshow, the image would be displayed correctlly. Is there any difference between the imageItem and the imshow function in matplotlib?

Luke Campagnola

unread,
Mar 5, 2014, 8:19:04 PM3/5/14
to pyqt...@googlegroups.com
Probably the image was transposed, not rotated. PyQtGraph interprets the axes of image data as [width, height], which is the opposite of most other standards. Unfortunately this behavior must be kept for backward compatibility, but I will be adding a config option soon that will cause it to interpret axes in the opposite order. 

For now, simply transposing the image data before giving it to pyqtgraph should suffice:   pg.image( img_data.T )
This operation does not incur any performance overhead.


On Wed, Mar 5, 2014 at 7:36 PM, <honestappl...@gmail.com> wrote:
Hi, I am newbie to pyqtgraph.I opened the image file with scipy.misc.imread which stored the image data into numpy array and then attached the numpy array to the imageItem. Then, I found that the image was displayed with 90 degree rotation counter-clockwise. If I used the matplotlib.imshow, the image would be displayed correctlly. Is there any difference between the imageItem and the imshow function in matplotlib?

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/c126bba3-1a44-4759-a50e-f36e811c3ade%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

honestappl...@gmail.com

unread,
Mar 7, 2014, 8:25:24 AM3/7/14
to pyqt...@googlegroups.com
No, it was not transposed. When I run the following code, I found the image was rotated 270 degree counter-clockwise.

self.imageItem.setImage(targetImage.T)

Perhaps I should rearrange the image data matrix.

在 2014年3月6日星期四UTC+8上午9时19分04秒,Luke Campagnola写道:

Luke Campagnola

unread,
Mar 7, 2014, 10:04:55 AM3/7/14
to pyqt...@googlegroups.com
On Fri, Mar 7, 2014 at 8:25 AM, <honestappl...@gmail.com> wrote:
No, it was not transposed. When I run the following code, I found the image was rotated 270 degree counter-clockwise.

self.imageItem.setImage(targetImage.T)

Perhaps I should rearrange the image data matrix.

A transpose and a vertical flip, then  (which is the same as a rotation). Try:

    self.imageItem.setImage(targetImage[:, ::-1].T)


honestappl...@gmail.com

unread,
Mar 7, 2014, 4:49:17 PM3/7/14
to pyqt...@googlegroups.com
Yes, thank you.

在 2014年3月7日星期五UTC+8下午11时04分55秒,Luke Campagnola写道:

Nicolas Coquelle

unread,
Jul 4, 2016, 10:02:42 AM7/4/16
to pyqtgraph
Hello Luke, 

I was wondering if this option (interpret axes in the opposite order) is available in the current pyqtgraph version. 
(Did not find in the documentation).

Thanks in advance, 

Nico.

Vincent Le Saux

unread,
Jul 4, 2016, 12:48:51 PM7/4/16
to pyqtgraph
Hi,

To my knowledge, not yet.

Vincent

Luke Campagnola

unread,
Jul 9, 2016, 2:06:18 AM7/9/16
to pyqt...@googlegroups.com
I am working on this currently. See:

For images it seems to work; for ROIs there are still some issues.
I also have pending PRs that add unit tests for ImageItem and ROI that need to go in before this one.

Reply all
Reply to author
Forward
0 new messages