spatialdata icon indicating copy to clipboard operation
spatialdata copied to clipboard

Keep polygon interior during vectorization

Open quentinblampey opened this issue 9 months ago • 0 comments

There is a minor issue in spatialdata._core.operations.vectorize._vectorize_mask

The interior is removed when we have a mask with an interior, for instance this one:

import numpy as np

mask = np.zeros((100, 100), dtype=np.uint8)
mask[10:90, 10:90] = 1
mask[40:60, 40:60] = 0
mask[45:55, 45:55] = 1

Image

Instead, it will create three polygons nested inside each other. A good behavior should be one of the following:

  • one polygon with an interior, and another polygon (for the small square)
  • or one multipolygon composed of the two above polygons

I'm not sure if it's very easy to fix. I'll investigate later.

quentinblampey avatar Apr 02 '25 11:04 quentinblampey