Transform to Threshold Image for Tissue
Is your feature request related to a problem? Please describe. A transform that given a RGB image (a tile from histopathology image or a WSI at low resolution), apply thresholding algorithm to distinguish the tissue from the background, and outputs a binary mask and some statistics.
A slightly different use-case is when you tile the input and the thresholded output is binary per tile. This results in the same low-res binary mask but is accomplished in a different way. Usually this is done at an intermediate resolution with the output being low res.
@JHancox Thanks for providing the use case. Could you please elaborate a bit?
- What is the purpose of that mask?
- Is threshold filter each pixel of the tile or the entire tile?
The purpose of the binary mask (foreground/background) is the same as usual - to eliminate the background from any computation. The way it might work is:
- Ingest the WSI at the lowest feasible resolution
- Split it into tiles
- Evaluate whether each tile is above or below some threshold using the pixel values and some function (e.g. variance, mean value, otsu etc)
- Return a binary image with each pixel representing a tile.
- Use the mask so that, say, inference is only done on foreground tissue
Hi @drbeh, @JHancox
I'm still a bit missing the point, is MONAI's ForegroundMask not up to the task at the moment, and why?
https://github.com/Project-MONAI/MONAI/blob/9689abf834f004f49ca59c7fe931caf258da0af7/monai/transforms/intensity/array.py#L2196
Hi @KumoLiu, it might be. Please check and verify the requested features are already addressed in ForegroundMask. Thanks
Hi @JHancox, I didn't quite understand what mean "Return a binary image with each pixel representing a tile", does it mean for each tile to return a binary image to represent the corresponding mask? It seems we can ingest the WSI at the lowest feasible resolution with WSIReader, split it into tiles with GridPatch, and in each patch use ForegroundMask to get a binary mask. If I understand correctly, the components in MONAI maybe already meet the requirements. Do I missing anything, I would be appreciated it if you can correct me! Thanks!
Hi @KumoLiu , So, I'm probably making it sound more complicated that it is! If you have an input image of say 1000 x 1000 (x3) and you want to threshold tiles of 50x50(x3), then at the end of the process, you end up with a binary image/mask of dimension 20 x 20 - or a list of coordinates of foreground patches. As @drbeh says, if this requirement can be met by existing features - fantastic! What this is, hopefully building towards is the ability to use this dynamically, within a DataReader that can then yield foreground patches. Hope that helps.