PyTorch version of `skimage.draw.polygon`? coordinates to mask

Hello everyone.

I’ve been trying quite a bit to figure out a solution here.

I’d like to go from a set of points to a masked image representation of these points. (Filling the pixels within)

skimage.draw.polygon allows me to do just that.

Is there anyone that can assist with a PyTorch implementation?

Many thanks!

1 Like

The internal _polygon method used in skimage seems to iterate the passed coordinates and appends the indices which are inside the polygon, so you could try to adapt this code in PyTorch and reuse it.

Good find! Thank you @ptrblck - Somehow I did not think of looking into the .pyx-file. This is awesome. Will post my version as its complete.

I am also facing the same problem, can I ask if you have solved it ?

I haven’t yet.

I’m dissatisfied with the skimage implementation, as it loops over all the pixels in the image.

Ideally I think the operation should be vectorized, and this I haven’t had time for at present.