State Bradley threshold equivalence in Niblack docstring#3891
State Bradley threshold equivalence in Niblack docstring#3891stefanv merged 3 commits intoscikit-image:masterfrom
Conversation
skimage/filters/thresholding.py
Outdated
|
|
||
| The Bradley threshold is a particular case of the Niblack | ||
| one, being equivalent to | ||
| >>> threshold_niblack(image, k=0) * (1-q) |
There was a problem hiding this comment.
(a) I think the syntax might require some spacing for proper formatting in the docs:
| >>> threshold_niblack(image, k=0) * (1-q) | |
| >>> q = 0.95 | |
| >>> t_brad = threshold_niblack(image, k=0) * (1-q) | |
(b) I used quantile in my explanation because I think they are to percentiles what radians are to degrees, but based on your previous PR I imagine they use percentiles. Therefore I presume they used q = 1. And further, no, they must have used q = 0, because otherwise it reduces to 0 everywhere. (ie they used (1-q) = 1.
Other than those two comments, the PR looks good to me, thanks! =)
There was a problem hiding this comment.
Hey Juan,
now I'm kinda confused. 😅
Yep, they use percentiles. Their algorithm shows (page 4):
20: if (in[i, j) * count) <= (sum * (100-t)/100) then
Then Bradley's should be equal to threshold_niblack() with k=0 only, as before? 😄
There was a problem hiding this comment.
Well if t = 100, that number is equal to 0! So someone made a mistake somewhere. =)
There was a problem hiding this comment.
Also, (100-t)/100 is equal to (1-q) where q=t/100, ie quantile is the percentile divided by 100.
There was a problem hiding this comment.
someone made a mistake somewhere. =)
It was me, of course. 😄 Let's try to rewrite this then...
sciunto
left a comment
There was a problem hiding this comment.
A minor comment and I'm ok with this one.
Is there a testcase that checks the equivalence?
skimage/filters/thresholding.py
Outdated
| .. [1] Niblack, W (1986), An introduction to Digital Image | ||
| Processing, Prentice-Hall. | ||
| .. [2] D. Bradley and G. Roth, "Adaptive thresholding using Integral Image" | ||
| Journal of Graphics Tools 12(2), pp. 13-21, 2007. |
There was a problem hiding this comment.
Please, append :DOI:10.1080/2151237X.2007.10129236
skimage/filters/thresholding.py
Outdated
| The Bradley threshold is a particular case of the Niblack | ||
| one, being equivalent to | ||
|
|
||
| >>> threshold_niblack(image, k=0) |
There was a problem hiding this comment.
| >>> threshold_niblack(image, k=0) | |
| >>> q = 1 | |
| >>> bradley_t = threshold_niblack(image, k=0) * q | |
| for some value ``q``. By default, Bradley and Roth use ``q=1``. |
There was a problem hiding this comment.
Done. Thanks for your help!
|
This PR breaks the doctests, see https://travis-ci.org/scikit-image/scikit-image/jobs/532551815#L2615. |
|
Dang, I remembered to define |
Description
Some info on Bradley and Niblack's thresholds equivalence (see #3877 @jni comments).
Checklist
- [ ] Docstrings for all functions- [ ] Gallery example in./doc/examples(new features only)- [ ] Benchmark in./benchmarks, if your changes aren't covered by anexisting benchmark
- [ ] Unit tests- [ ] Clean style in the spirit of PEP8For reviewers
later.
__init__.py.doc/release/release_dev.rst.@meeseeksdev backport to v0.14.x