ANN: qimage2ndarray - converting between QImages and numpy.ndarrays
Hi, I have just uploaded a first release of qimage2ndarray, a tiny python extension for quickly converting between QImages and numpy.ndarrays (in both directions). These are very common tasks when programming e.g. scientific visualizations in Python using PyQt4 as the GUI library. Similar code was found in Qwt and floating around on mailing lists, but qimage2ndarray has the following unique feature set: * Supports conversion of scalar and RGB data, with arbitrary dtypes and memory layout, with and without alpha channels, into QImages (e.g. for display or saving using Qt). * Using a tiny C++ extension, qimage2ndarray makes it possible to create ndarrays that are *views* into a given QImage's memory. This allows for very efficient data handling and makes it possible to modify Qt image data in-place (e.g. for brightness/gamma or alpha mask modifications). * qimage2ndarray is stable and unit-tested: * proper reference counting even with views (ndarray.base points to the underlying QImage) * handles non-standard widths and respects QImage's 32-bit row alignment * Masked arrays are also supported and are converted into QImages with transparent pixels. * Supports value scaling / normalization to 0..255 for convenient display of arbitrary NumPy arrays. The extension is open source, BSD-licensed, and available via PyPI or here: http://kogs-www.informatik.uni-hamburg.de/~meine/software/qimage2ndarray/ I hope this is useful to many of you and look forward to your feedback, Hans PS: Now that I am announcing this, I suddenly have the feeling that I should have talked with some lawyer (or Phil) about possible license issues because of PyQt. I really hope there will not turn out to be problems with this.
2009/12/2 Hans Meine
PS: Now that I am announcing this, I suddenly have the feeling that I should have talked with some lawyer (or Phil) about possible license issues because of PyQt. I really hope there will not turn out to be problems with this.
The PyQt license has an explicit provision that allows you to build BSD-licensed libraries and applications that use PyQt. The final application as a whole (i.e. when combined with PyQt) must be distributed according to the appropriate PyQt license, either GPL or Commercial, of course, but your BSD library is fine to include in that application. Look at the file GPL_EXCEPTION.TXT . -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Cool. Thanks!
I will take a look at this. We have some code in scikits.image that
creates a QImage from the numpy data buffer for display. But I have
only implemented it for RGB888 so far. So you may have saved me some
time :)
Cheers!
Chris
2009/12/2 Hans Meine
Hi,
I have just uploaded a first release of qimage2ndarray, a tiny python extension for quickly converting between QImages and numpy.ndarrays (in both directions). These are very common tasks when programming e.g. scientific visualizations in Python using PyQt4 as the GUI library.
Similar code was found in Qwt and floating around on mailing lists, but qimage2ndarray has the following unique feature set:
* Supports conversion of scalar and RGB data, with arbitrary dtypes and memory layout, with and without alpha channels, into QImages (e.g. for display or saving using Qt).
* Using a tiny C++ extension, qimage2ndarray makes it possible to create ndarrays that are *views* into a given QImage's memory.
This allows for very efficient data handling and makes it possible to modify Qt image data in-place (e.g. for brightness/gamma or alpha mask modifications).
* qimage2ndarray is stable and unit-tested:
* proper reference counting even with views (ndarray.base points to the underlying QImage)
* handles non-standard widths and respects QImage's 32-bit row alignment
* Masked arrays are also supported and are converted into QImages with transparent pixels.
* Supports value scaling / normalization to 0..255 for convenient display of arbitrary NumPy arrays.
The extension is open source, BSD-licensed, and available via PyPI or here:
http://kogs-www.informatik.uni-hamburg.de/~meine/software/qimage2ndarray/
I hope this is useful to many of you and look forward to your feedback, Hans
PS: Now that I am announcing this, I suddenly have the feeling that I should have talked with some lawyer (or Phil) about possible license issues because of PyQt. I really hope there will not turn out to be problems with this. _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (3)
-
Chris Colbert
-
Hans Meine
-
Robert Kern