Adding threshold_bradley.#3877
Conversation
|
Hello @alexandrejaguar! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
|
Hi everyone, |
| # checking condition for Bradley threshold | ||
| image = image * block_size ** 2 | ||
| thresh_image = image - int_image * (100 - bright_perc) / 100 | ||
| thresh_image = thresh_image > 0 |
There was a problem hiding this comment.
@alexandrejaguar a bit of rearrangement shows that the resulting threshold image should be integral_image * (1 - q), where q is a quantile:
result = (image - integral_image * (1 - q) > 0)
result = (image > integral_image * (1 - q))The lower form is the format we want for applying a threshold, ie normally we would say image > t for some threshold t.
However, rearranging also shows that this is equivalent to niblack thresholding with k=0, so I'm not sure this addition needs to happen. Maybe a note on that function is sufficient. Otherwise, the implementation should just call that function, since it is n-dimensional rather than 2D only.
@scikit-image/core any thoughts on this?
There was a problem hiding this comment.
Note also that the implementation above has a mistake: the integral image needs to be divided by the window size, otherwise we are looking at the sum of the surrounding window, not the mean as the docstring suggests.
There was a problem hiding this comment.
Better of we don't have to. Perhaps add a line to niblack stating the equivalence?
There was a problem hiding this comment.
Sorry, I spoke too quickly: the q/bright_perc muddles things up. It's actually equivalent to Niblack times (1-q).
There was a problem hiding this comment.
I don't see a problem on putting that on niblack's notes, and maybe an example on the docs. Is it okay?
|
Closing this as it feels redundant (a particular case of |
Description
Revisiting #919.
Checklist
./doc/examples(new features only)./benchmarks, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py.doc/release/release_dev.rst.@meeseeksdev backport to v0.14.x