[Numpy-discussion] ANN: qimage2ndarray - converting between QImages and numpy.ndarrays
Wed Dec 2 17:52:48 CST 2009
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
2009/12/2 Hans Meine <email@example.com>:
> 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
> * 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:
> I hope this is useful to many of you and look forward to your feedback,
> 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
More information about the NumPy-Discussion