Skip to content

Fix geojson creation with ring-shaped masks - #19

Open
leop-gne wants to merge 1 commit into
cpath-ukk:mainfrom
leop-gne:main
Open

Fix geojson creation with ring-shaped masks#19
leop-gne wants to merge 1 commit into
cpath-ukk:mainfrom
leop-gne:main

Conversation

@leop-gne

Copy link
Copy Markdown

When a mask has a ring-shaped object in it, such as a pen mark that forms a closed loop, the current geojson code will create a filled disk in the geojson. Additionally, the use of cv2 means the original mask is not recoverable from the resulting geojson. This is a proposed fix, though I've only implemented it in 01_WSI_inference_OPENSLIDE_QC and haven't updated the dependencies since I'm not certain which GeoPandas and shapely versions work with the current dependencies.

Here's an example of a ring-shaped object and the mask created by the current method and the proposed method.
image

The new method displays the polygon as being offset by half a pixel from the original mask, but this is solely a display effect from the convention of whether a vertex designates the bottom right corner of a pixel or the center of the pixel at display time. The original mask is recoverable with rasterio.features.rasterize:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant