Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Reduce the default tolerance in threshold_li #3622

Merged
merged 2 commits into from
Mar 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions skimage/filters/thresholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ def threshold_li(image, *, tolerance=None):

tolerance : float, optional
Finish the computation when the change in the threshold in an iteration
is less than this value. By default, this is half of the range of the
input image, divided by 256.
is less than this value. By default, this is half the smallest
difference between intensity values in ``image``.

Returns
-------
Expand Down Expand Up @@ -578,8 +578,7 @@ def threshold_li(image, *, tolerance=None):
# Li's algorithm requires positive image (because of log(mean))
image_min = np.min(image)
image -= image_min
image_range = np.max(image)
tolerance = tolerance or 0.5 * image_range / 256
tolerance = tolerance or np.min(np.diff(np.unique(image))) / 2
jni marked this conversation as resolved.
Show resolved Hide resolved

# Initial estimate
t_curr = np.mean(image)
Expand Down