navigate.model.features.remove_empty_tiles.detect_tissue
- navigate.model.features.remove_empty_tiles.detect_tissue(image_data, percentage=0.0)
Detect tissue in an image and determine if it exceeds a specified percentage.
This function takes an image in the form of image data and detects tissue within the image. It calculates the percentage of tissue area with respect to the total number of cells in a 50-pixel boundary grid.
- Parameters:
image_data (ndarray) – A NumPy array representing the image data. The image should be preprocessed and ready for tissue detection.
percentage (float, optional (default: 0.0)) – The threshold fraction of tissue grid cells, from 0 to 1, for the image to be considered as containing tissue. If the detected tissue percentage is strictly greater than this value, the function returns True; otherwise, it returns False.
- Returns:
True if the detected tissue fraction is strictly greater than the specified fraction; False otherwise.
- Return type:
bool
Notes
The function counts tissue grid cells within the detected row boundaries after downsampling the thresholded image by a factor of 50.
It calculates the tissue percentage by dividing the number of tissue squares by the total possible squares in the image.
The width of the sliding window is determined by the ‘width’ variable.
Examples
Check whether tissue covers more than half of the boundary grid:
image_data = np.zeros((100, 100), dtype=np.uint16) image_data[:50, :] = 100 result = detect_tissue(image_data, percentage=0.5)
Here the upper two of four 50-pixel grid cells contain tissue. The fraction is exactly 0.5, so the strict comparison returns
False.