[Image-SIG] Comparison of PIL and GD speed for setting pixels through python
Douglas Bagnall
douglas at paradise.net.nz
Sun Feb 4 23:43:56 CET 2007
hi John,
> Method Time (s) Times slower than fastest
> +-----+ +-------+ +------------------------+
> ctypes,c,GD raw 0.00082 1.0
> ctypes,c,GD 0.00177 2.2
> PIL - 'load' 0.03226 39.4
> ctypes, GD 0.14428 176.4
> PIL, numpy * 0.26271 321.2
> PIL - 'point' 0.37180 454.5
>
You can also access raw PIL image data via C, so your top line,
"ctypes,c,GD raw" should be just as applicable to PIL as GD. Or is
there some reason this is not so? From memory, you'd pry open the
im.im object, and use something like im->image32[y][x] to access each
pixel.
Also, your C functions boil down to variations of memset. Have you
considered trying that? Another option is PIL's paste(colour, box)
method. I suspect you are ignoring these two because somewhere you
say "one pixel at a time", but as far as I can tell your routines
don't allow for that pixel to vary, so there is actually no
difference. im.paste(colour, (0, 0, width, height)) is functionally
the same as your test functions; inside it probably looks much like
your setPixelsRaw.
douglas
More information about the Image-SIG
mailing list