[SciPy-User] ROI, the sequel

Zachary Pincus zachary.pincus@yale....
Tue Aug 3 21:06:48 CDT 2010


The task you want to accomplish is called "polygon rasterization", and  
I have long looked for a simple python (or better, portable C that I  
could use from anywhere) module that does this well. (Ideally with  
optional antialiasing.) I really haven't found much... any graphics  
toolkit (e.g. for throwing up a GUI) can be convinced to rasterize to  
a memory buffer, which can be converted to a numpy array, but it's not  
simple or particularly portable. Lately I use OpenGL, but again not  
exactly simple.

Perhaps the python bindings for the AGG library would be the best bet,  
but this is a pretty simple problem to solve with such a heavyweight  
dependency. Does anyone else know of any simple rasterization libs out  


On Aug 3, 2010, at 8:05 PM, Thøger Emil Juul Thorsen wrote:

> Hello list;
> I need a tool for polygon clipping of 2d NumPy arrays, but I cannot  
> seem
> to find anything. Shapely will only export the vertices of the  
> polygon.
> NXutils and patches in matplotlib seem to be purely visual, in any  
> case
> I cannot see how they would be saved as arrays in data coordinates.
> There is a very neat IDL routine, POYFILLV which returns a 1d array of
> the (1d) indices of the pixels that are inside the polygon, sort of  
> like
> a "where" function. Is there anything like it out there for numpy
> arrays?
> Best;
> Emil
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-User mailing list