[Image-SIG] Speeding up an image transformation in C

Nils Olaf de Reus nils.de.reus at ivm.vu.nl
Thu Nov 12 14:54:18 CET 2009


On Mon, 9 Nov 2009 17:24:05 +0100, Grzegorz Adam Hankiewicz
<ghankiewicz at rastertech.es> wrote:
> Hello.
>
> I have a small python algorithm similar to a floodfill that works slow
> in python. Is there any documentation on how I could write a C
extension
> to speed it up? Are there any dev headers I can compile against to
> handle an Image from C?


I would recommend in this case that you use cython. It allows you to
create a C implementation of your algorithm with a python front end, and
compile it into an extension which you can then import into regular
python code. If you use a numpy array to represent your image, it should
work exceptionally well. There is a cython tutorial for using C code
with python aimed specifically at numpy. It can be found here:
http://wiki.cython.org/tutorials

====================================================
Drs. Nils Olaf de Reus
Department of Spatial Analysis and Decision Support
Institute for Environmental Studies, VU Amsterdam
De Boelelaan 1087, 1081HV The Netherlands
Website: http://www.ivm.vu.nl
Email: nils.de.reus at ivm.vu.nl
====================================================




More information about the Image-SIG mailing list