Handling very large images

254 views
Skip to first unread message

Luke

unread,
Nov 19, 2013, 9:11:20 PM11/19/13
to pyqt...@googlegroups.com
Superb package, very happy I stumbled upon it, it's perfect for what our research group is after.
I just have an issue with large numpy arrays (shape larger than 40000x60) being drawn as images. The problem is that if I don't cut down the array size by clipping the data, then images don't draw correctly beyond some size. The screenshot below shows the last 5th or so being drawn incorrectly with some funky colours at the top right. Creating an ROI and dragging it around works fine on the first 4/5ths of the data, but the end erases out along the path of the ROI.

I'm guessing this is due to the size of the image. If so, is there a way to enable mipmapping or some other way to handle very large images?

[Using canopy python 2.7.3 with pyqtgraph 0.9.7 and pyside 1.1.1-2]

Luke Campagnola

unread,
Nov 20, 2013, 2:04:31 PM11/20/13
to pyqt...@googlegroups.com
On Tue, Nov 19, 2013 at 9:11 PM, Luke <lwik...@gmail.com> wrote:
I just have an issue with large numpy arrays (shape larger than 40000x60) being drawn as images. The problem is that if I don't cut down the array size by clipping the data, then images don't draw correctly beyond some size. The screenshot below shows the last 5th or so being drawn incorrectly with some funky colours at the top right. Creating an ROI and dragging it around works fine on the first 4/5ths of the data, but the end erases out along the path of the ROI.

The reason for this is very likely that either QImage or QPainter.drawImage (or both) are limited to 2**15 pixels along any dimension  (see: http://stackoverflow.com/a/7080898/643629). An easy solution is to simply downsample the data before displaying it, but then the ROI plot would have decreased resolution as well. That could be fixed by writing in some custom ROI-handling code.

The best solution to this is to have ImageItem automatically downsample and clip the image data when it is displayed. This feature has been on my wish-list for a long time, and turns out to be quite simple to implement. I have created a new branch on github for testing this feature; you can see the relevant changes here:  https://github.com/lcampagn/pyqtgraph/commit/0a5cb62a6f6f8687f52037f80691e719abe75d81

To make this feature complete, the ImageItem would need to clip the data as well so that the problem does not reappear after zooming in. This feature will probably not make it into the next release, but there are plenty of options for backporting the code into your own project. Let me know if you would like assistance with that..


Luke

Christian Ambros

unread,
Nov 27, 2013, 2:50:03 PM11/27/13
to pyqt...@googlegroups.com
Hi,

there is a different solution, too. Just convert the image to fits and let pyfits handle it. I had not issues with 32x 8mpx images, yet.
The data is read in as numpy array, too, but it's headers are now stored in dictionaries which helps a lot.

What kind of data is stored in these images? Sounds like some kind of spectra maybe...

... and I completly agree: it is a superb package.
cheers,
Christian
Reply all
Reply to author
Forward
0 new messages