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 image area using a sliding window approach.
Parameters:
- image_datandarray
A NumPy array representing the image data. The image should be preprocessed and ready for tissue detection.
- percentagefloat, optional (default: 0.0)
The minimum required percentage of tissue in the image for it to be considered as containing tissue. If the detected tissue percentage is greater than or equal to this value, the function returns True; otherwise, it returns False.
Returns:
- bool
True if the detected tissue percentage is greater than or equal to the specified percentage; False otherwise.
Notes:
The function applies a sliding window approach to count tissue squares within the image.
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.
Example:
Given an image data array and a percentage threshold of 0.5: ``` image_data = np.array([[0, 0, 1, 1, 1],
[0, 0, 0, 1, 1], [1, 0, 0, 0, 0], [1, 1, 0, 0, 1]])
result = detect_tissue(image_data, 0.5) ```
The function would return True, as the detected tissue percentage in the image (10 out of 20 squares) is greater than or equal to 0.5.