Skip to content

Thresholds Modules

Functions for calculating thresholds.

threshold(image, method=None, otsu_threshold_multiplier=None, **kwargs)

Thresholding for producing masks.

Parameters

image : npt.NDArray 2-D Numpy array of image for thresholding. method : str Method to use for thresholding, currently supported methods are otsu (default), mean and minimum. otsu_threshold_multiplier : float Factor for scaling the Otsu threshold. **kwargs : dict Additional keyword arguments to pass to skimage methods.

Returns

float Threshold of image using specified method.

Source code in topostats/thresholds.py
def threshold(image: npt.NDArray, method: str = None, otsu_threshold_multiplier: float = None, **kwargs: dict) -> float:
    """
    Thresholding for producing masks.

    Parameters
    ----------
    image : npt.NDArray
        2-D Numpy array of image for thresholding.
    method : str
        Method to use for thresholding, currently supported methods are otsu (default), mean and minimum.
    otsu_threshold_multiplier : float
        Factor for scaling the Otsu threshold.
    **kwargs : dict
        Additional keyword arguments to pass to skimage methods.

    Returns
    -------
    float
        Threshold of image using specified method.
    """
    thresholder = _get_threshold(method)
    return thresholder(image, otsu_threshold_multiplier=otsu_threshold_multiplier, **kwargs)

handler: python options: docstring_style: numpy rendering: show_signature_annotations: true