I have thousands of polygons given their 4 corner coordinates (quadrilaterals) and would like to convert them to a raster representation as a numpy 2d array. A lot of gridding algorithms exist like the popular scanline fill in graphics. (see http://www.cs.rit.edu/~icss571/filling/how_to.html or http://cs.uvm.edu/~rsnapp/teaching/cs274/lectures/scanlinefill.pdf )
Octave implements this in the poly2mask function (e.g. http://octave.sourceforge.net/image/function/poly2mask.html).
Is there a similar function also in Numpy? I still don't get how this algorithms works in detail and, thus, I would be very grateful if you can give me some hints on how to implement it in Python/Numpy efficiently.
Or would it be better to code it in CPython (which I am not familiar with either) for speed reasons?