What is the fastest way to scale and display an image in Python?

I need to display a two-dimensional numpy.array int16 at a speed of 20 frames per second or so. Using Matplotlib imshow pinches anything above 10 frames per second. Obviously, there are some problems with scaling and interpolation. I must add that the dimensions of the array are unknown, but it will probably be about thirty-four hundred.

This is data from a sensor that must have a real-time display, so data must be re-sampled on the fly.

+6
python matplotlib animation image-scaling
source share
1 answer

The fastest way to display 30x400 data points is:

Use OpenGL color arrays

If you can quickly transform your data into what OpenGL understands as a color array, you can create a vertex array that describes the quadrants, one for each sensor, and then update the color matrix and do it spelling on the screen.

Use OpenGL Textures

If you can quickly convert your data points to an opengl texture, you can draw a single square with fixed UV coordinates attached to that texture.

Use pygame

Pygame supports the conversion of Numpy / Numarray to surfaces, Pygame can then convert surfaces that include re-sampling, after re-sampling you can split it on the screen.

miscellanea

pyglet makes opengl easy

+6
source share

All Articles