PYME.Analysis.thresholding module¶
- PYME.Analysis.thresholding.isodata(img, tol=0.001)¶
correct isodata implementation - slower than above tolerance indicates fraction of data range when delta is deemed not to have changed
- PYME.Analysis.thresholding.isodata_f(img, nbins=255, bin_spacing='linear', tol=1e-05)¶
calculate isodata threshold - does iterations on histogrammed data rather than raw data to improve speed
img - the image data nbins - the number of bins used for the histogram
- PYME.Analysis.thresholding.otsu(image, nbins=256, bin_spacing='linear')¶
Return threshold value based on Otsu’s method.
Adapted from the skimage implmentation to allow non-linear bins
- Parameters
- image(N, M) ndarray
Grayscale input image.
- nbinsint, optional
Number of bins used to calculate histogram. This value is ignored for integer arrays.
- Returns
- ——-
- thresholdfloat
Upper threshold value. All pixels with an intensity higher than this value are assumed to be foreground.
- Raises
- ——
- ValueError
If image only contains a single grayscale value.
- References
- ———-
- .. [1] Wikipedia, https://en.wikipedia.org/wiki/Otsu’s_Method
- Examples
- ——–
- >>> from skimage.data import camera
- >>> image = camera()
- >>> thresh = threshold_otsu(image)
- >>> binary = image <= thresh
- Notes
- —–
- The input image must be grayscale.
- PYME.Analysis.thresholding.signalFraction(img, frac, nbins=5000)¶
threshold to include a certain fraction of the total signal