NKI-AI / ahcore

Ahcore is the AI for Oncology core computational pathology toolkit
Apache License 2.0
15 stars 1 forks source link

Implement better tile aggregation #98

Closed AjeyPaiK closed 1 month ago

AjeyPaiK commented 1 month ago

This PR implements StitchingMode.AVERAGE along with StitchingMode.MAXIMUM in ahcore.readers for better tile stitching.

Functionality of the stitching modes illustrated through a test case:

  1. We make a 2x2 grid with tiles of size (200,200) with an overlap of (50,50).
  2. Each tile has a different color and at the overlaps, the colors are mixed as shown below.
  3. In the overlap regions, the portion where two tiles overlap has a value of 4, the portions where two tiles overlap has a value of 2. The black regions have a value of 1.
  4. The overlap regions array is used for the averaging operation or to calculate maximum values.
  5. The test I have implemented checks for colors in the different overlap regions and non-overlapping regions of the stitched image and asserts for correctness.
Stitched Tile Overlap Regions
stitched_tile overlap_count

What is the effect of this on the quality of segmentation outputs? Check below.

Before After Averaging After Averaging with large tile_overlap
before after_averaging after_gaussian