[SciPy-User] Points with given distance to a polygon

Zachary Pincus zachary.pincus@yale....
Mon Jul 26 13:26:49 CDT 2010


> I am working on a project where I am defining some regions of  
> interest.
> I have a 2200x2200 px 2D Array in which my ROI is defined by a  
> polygon.
> However, my data are smoothed by a gaussian kernel of width 300px,  
> and I
> would like to draw some lines indicating this inner 150px distance to
> the borders of the ROI. I cannot come up with any way to do this, does
> anyone have an idea?

Two broad options spring to mind:
(1) Geometric -- shrink the polygon along the normals to the vertices.  
[Oh, I see that eat has given pseudocode for same... good]
(2) Gridded -- rasterize the polygon to a binary mask (no tools for  
this in scipy, I fear... but if you're handy with opengl or something,  
that's not too hard), and then use scipy.ndimage to erode or dilate  
the mask as necessary.

Zach


More information about the SciPy-User mailing list