[Numpy-discussion] Generalized rectangle intersection. (Was: Array blitting)

Stefan van der Walt stefanv at berkeley.edu
Mon Jul 10 14:31:15 EDT 2017


On Mon, Jul 10, 2017, at 01:34, Jerome Kieffer wrote:
> On Sun, 9 Jul 2017 23:35:58 +0200
> Mikhail V <mikhailwas at gmail.com> wrote:
> 
> > disclaimer: I am not a past contributor to numpy and I don't know
> > much about github, and what pull request means. So I just put the
> > examples here.
> > 
> > So in short, the proposal idea is to add a library function which
> > calculates the intersection
> > area of two rectangles, generalized for any dimensions.
> 
> I am using this kind of clipping as well but in the case you are
> suggesting the boxes looks aligned to the axis which is limiting to me.
> The general case is much more complicated (and interesting to me :)
> 
> Moreover the scikit-image may be more interested for this algorithm.

We use rectangular clipping in scikit-image, but general polygon
clipping is easy thanks to Matplotlib's wrapping of the AGG library. 
Here's how to do it:

https://github.com/scikit-image/scikit-image/blob/master/skimage/_shared/_geometry.py#L6

Stéfan


More information about the NumPy-Discussion mailing list