How to know if a point is outside a set of points in an image?

Viewed 68

enter image description here

If we take any point from this image, how can we tell if that point is inside these set of points, when we have the positions of all these points?

1 Answers

You can use shapely:

Sample code below:

from shapely.geometry import Point
from shapely.geometry.polygon import Polygon

point = Point(0.5, 0.5)
polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])
print(polygon.contains(point))
Related