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

Overhauled convert_mask_to_xml fixing #48 #50

Closed JoeySpronck closed 7 months ago

JoeySpronck commented 7 months ago

Overhauled convert_mask_to_xml.py script in convert_mask_to_xml_or_json.py, (partially) fixes #48: 1) hierarchy aware cv2_polygonize allows removal of holes, since the previous fill_holes option would exclude regions that are inside holes af regions of the same class. 2) improved convert_polygons_to_annotations.py, since the holes and type cannot be set anymore via dict since these are class properties now in the current state of WSD, not fully sure how this works though. 3) made large improvements in the main function, (I) combining the improved functions above, (II) improved mask handling, allowing to create polygons for label 0, if you dont want to make polygons for label 0 you can specify this in values, (III) improved handling of spacings of the mask and the corresponding WSI, also added processing spacing that will decide on which spacing the mask will be read and the pologons will be made, writes to spacing using ratios of WSI for correct reading of xmls in WSI viewers, (IV) added option to export additional json, (V) convert annotations to json now accepts optional spacing ratio, on second glance I should have built that into write_json_annotation, (VI) option to simplyfy polygons and take the union (VII) other minor improvemenst and example usage