[PyQt] Pixel Manipulation Very Slow?

Jeremy Sanders jeremy at jeremysanders.net
Fri Aug 20 13:44:17 BST 2010


zhang jian wrote:

> Just one image changed in red channel. It took about 5 seconds to redraw a
> 1280 X 720 image any time I changed Kd. Far from interactive. I'd like to
> know is there any way to do stuff like that faster? Or calculating a
> million pixels in PyQt is just a bad idea? Any advice should be
> appreciated.

Python is quite slow for doing pixel-by-pixel things.

You could try to get Qt to do the work for you. If you're just changing 
weighting, you could paint images with different levels of transparency.

If you need to do the calculation, you can do it with numpy, and convert the 
array to a Qt image - see the slowNumpyToQImage function here 
http://svn.gna.org/viewcvs/veusz/trunk/widgets/image.py?rev=1280&view=markup 
for some evil Python code which converts a numpy array to an image.

Otherwise you need to write some C++ to do the pixel manipulation. You can 
then write a SIP wrapper to let you call it from Python.

Jeremy

-- 
http://www.jeremysanders.net/



More information about the PyQt mailing list