DIAGNijmegen / pathology-whole-slide-data

A package for working with whole-slide data including a fast batch iterator that can be used to train deep learning models.
https://diagnijmegen.github.io/pathology-whole-slide-data/
Apache License 2.0
86 stars 24 forks source link

Mask to xml/json overhaul #48 #49

Closed JoeySpronck closed 7 months ago

JoeySpronck commented 7 months ago

Overhauled the entire convert_mask_to_xml.py script with several key enhancements:

  1. Enabled hierarchy-aware cv2_polygonize to address the issue of excluding regions within holes of the same class, eliminating the need for the previous fill_holes option.

  2. Enhanced convert_polygons_to_annotations.py by updating how holes and types are set. The script now reflects the current state of WSD, where these are class properties. Note: Further clarification may be needed on the underlying mechanics.

  3. Significantly improved the main function with the following features:

    • (I) Merged the enhanced functions mentioned above.
    • (II) Upgraded mask handling, allowing polygon creation for label 0. Users can specify exclusion of label 0 polygons through custom values.
    • (III) Optimized mask and WSI spacing handling, with added processing spacing determining mask reading and polygon creation. Spacing is written using WSI ratios for accurate XML reading in WSI viewers.
    • (IV) Introduced an option for exporting additional JSON.
    • (V) Updated the convert_annotations_to_json function to accept an optional spacing ratio. A reconsideration suggests integrating this into write_json_annotation.
    • (VI) Added an option to simplify polygons and compute their union.
    • (VII) Other minor improvements and example usage