Question
I'm using PIL, and I have part of my code that requires finding which points are outside of a quadrilateral. If I have points like [(50, 20), (230, 40), (200, 190), (100, 200)]
, how can I quickly fill all the points outside this area with black?
I want a function like addBorder(points, img)
, where addBorder([(50, 20), (230, 40), (200, 190), (100, 200)], Image.open('lenna.png'))
would return:
What I've Found so Far
This answer looked useful until I realized the link was dead. If anyone knows if the page linked in that answer still exists somewhere else, I'd love to see it. I tried a few algorithms before I realized that they only worked for rectangles.
Can anyone help me?
I haven't found a way that doesn't involve checking every pixel, but I found my answer in rules for filling. I used the even-odd rule.