I have a list of morphological components $m$, a set of vertices for a polytope $P$ (at real number coordinates), and I'd like to be able to calculate a list of morphological components $m'$ that anywhere overlap the area of $P$. I can do this by approximating each pixel as a point, and calculating a winding number for these points with respect to $P$ to determine if they fall within the polygon's area. However, this is hardly an efficient strategy, and it's not as exact as I would like. My hope is to have a scheme to detect if the polygon crosses any square bright pixel region. Is there a clever way to do this that works very quickly?
I suspect the quickest approach will be to rasterize the polygon. For example
Create an example component matrix:
Define the polygon and rasterize it:
Identify values in
Check that the identified components do indeed overlap the polygon: