topostats.thresholds#
Functions for calculating thresholds.
Attributes#
Functions#
|
Thresholding for producing masks. |
|
Creator component which determines which threshold method to use. |
|
Calculate the Otsu threshold. |
|
Calculate the Mean threshold. |
|
Calculate the Minimum threshold. |
|
Calculate the Yen threshold. |
|
Calculate the triangle threshold. |
Module Contents#
- topostats.thresholds.LOGGER#
- topostats.thresholds.threshold(image: numpy.typing.NDArray, method: str = None, otsu_threshold_multiplier: float = None, **kwargs: dict) float [source]#
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:
Threshold of image using specified method.
- Return type:
float
- topostats.thresholds._get_threshold(method: str = 'otsu') collections.abc.Callable [source]#
Creator component which determines which threshold method to use.
- Parameters:
method (str) – Threshold method to use, currently supports otsu (default), mean, minimum, mean yen, and triangle.
- Returns:
Returns function appropriate for the required threshold method.
- Return type:
function
- Raises:
ValueError – Unsupported methods result in ValueError.
- topostats.thresholds._threshold_otsu(image: numpy.typing.NDArray, otsu_threshold_multiplier: float = None, **kwargs) float [source]#
Calculate the Otsu threshold.
For more information see skimage.filters.threshold_otsu().
- Parameters:
image (npt.NDArray) – 2-D Numpy array of image for thresholding.
otsu_threshold_multiplier (float) – Factor for scaling Otsu threshold.
**kwargs (dict) – Dictionary of keyword arguments to pass to ‘skimage.filters.threshold_otsu(**kwargs)’.
- Returns:
Threshold to be used in masking heights.
- Return type:
float
- topostats.thresholds._threshold_mean(image: numpy.typing.NDArray, otsu_threshold_multiplier: float = None, **kwargs) float [source]#
Calculate the Mean threshold.
For more information see skimage.filters.threshold_mean().
- Parameters:
image (npt.NDArray) – 2-D Numpy array of image for thresholding.
otsu_threshold_multiplier (float) – Factor for scaling (not used).
**kwargs (dict) – Dictionary of keyword arguments to pass to ‘skimage.filters.threshold_mean(**kwargs)’.
- Returns:
Threshold to be used in masking heights.
- Return type:
float
- topostats.thresholds._threshold_minimum(image: numpy.typing.NDArray, otsu_threshold_multiplier: float = None, **kwargs) float [source]#
Calculate the Minimum threshold.
For more information see skimage.filters.threshold_minimum().
- Parameters:
image (npt.NDArray) – 2-D Numpy array of image for thresholding.
otsu_threshold_multiplier (float) – Factor for scaling (not used).
**kwargs (dict) – Dictionary of keyword arguments to pass to ‘skimage.filters.threshold_minimum(**kwargs)’.
- Returns:
Threshold to be used in masking heights.
- Return type:
float
- topostats.thresholds._threshold_yen(image: numpy.typing.NDArray, otsu_threshold_multiplier: float = None, **kwargs) float [source]#
Calculate the Yen threshold.
For more information see skimage.filters.threshold_yen().
- Parameters:
image (npt.NDArray) – 2-D Numpy array of image for thresholding.
otsu_threshold_multiplier (float) – Factor for scaling (not used).
**kwargs (dict) – Dictionary of keyword arguments to pass to ‘skimage.filters.threshold_yen(**kwargs)’.
- Returns:
Threshold to be used in masking heights.
- Return type:
float
- topostats.thresholds._threshold_triangle(image: numpy.typing.NDArray, otsu_threshold_multiplier: float = None, **kwargs) float [source]#
Calculate the triangle threshold.
For more information see skimage.filters.threshold_triangle().
- Parameters:
image (npt.NDArray) – 2-D Numpy array of image for thresholding.
otsu_threshold_multiplier (float) – Factor for scaling (not used).
**kwargs (dict) – Dictionary of keyword arguments to pass to ‘skimage.filters.threshold_triangle(**kwargs)’.
- Returns:
Threshold to be used in masking heights.
- Return type:
float