Skip to content

get_eosin_mask

Get the binary eosin mask from the eosin channel.

Parameters:

Name Type Description Default
img_eosin ndarray

The eosin channel. Shape (H, W, 3).

required

Returns:

Type Description
ndarray

np.ndarray: The binary eosin mask. Shape (H, W).

Source code in src/histolytics/stroma_feats/utils.py
def get_eosin_mask(img_eosin: np.ndarray) -> np.ndarray:
    """Get the binary eosin mask from the eosin channel.

    Parameters:
        img_eosin (np.ndarray):
            The eosin channel. Shape (H, W, 3).

    Returns:
        np.ndarray:
            The binary eosin mask. Shape (H, W).
    """
    gray = rgb2gray(img_eosin)
    thresh = threshold_otsu(gray)
    eosin_mask = 1 - (gray > thresh)

    return eosin_mask.astype(bool)