Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix equalize_adapthist (CLAHE) for clip value 1.0, fix docstrings #4828
Conversation
A clip value of 1.0 is equal to not applying histogram clipping at all. When passed to equalize_adapthist (CLAHE), the expected behavior is therefore to perform AHE (i.e., CLAHE without clipping). The previous implementation, however, returned the input image.
The largest value in a histogram bin is determined by the kernel size, not by the number of gray levels.
The docstring said: > A clip limit smaller than 1 results in standard (non-contrast limited) > AHE. but limits of 0 or larger equal 1 result in AHE. Doc string corrected accordingly. Furthermore the docstring said: > The output image will have the same minimum and maximum value as the > input image. which is neither true for CLAHE nor for AHE. Removed sentence.
Why this test wouldn't be correct in your opinion? |
Hi François, I mentioned that briefly in #4827, but let me provide some more details here of how I understand the This understanding is also in line with the progression of histogram equalization over clip limits close to 1.0. Compare, for instance, clip values of 0.9, 0.95, 1.0, and 1.05. The last value performs AHE in the current implementation. The first two values perform CLAHE with decreasing effect of clipping, i.e., in the limit AHE. In this sequence, I would find it surprising if 1.0 would not perform AHE, but instead return the original image. |
I'm afraid, as far as I remember, that we implemented the test after reading the misbehavior. It seems to me that you are correct, any other opinion @scikit-image/core ? |
@@ -119,8 +117,7 @@ def _clahe(image, kernel_size, clip_limit, nbins): | |||
The number of "effective" graylevels in the output image is set by `nbins`; | |||
selecting a small value (eg. 128) speeds up processing and still produce |
mkcor
Jul 17, 2020
Contributor
Suggested change
selecting a small value (eg. 128) speeds up processing and still produce
selecting a small value (e.g. 128) speeds up processing and still produces
selecting a small value (eg. 128) speeds up processing and still produce | |
selecting a small value (e.g. 128) speeds up processing and still produces |
@@ -119,8 +117,7 @@ def _clahe(image, kernel_size, clip_limit, nbins): | |||
The number of "effective" graylevels in the output image is set by `nbins`; | |||
selecting a small value (eg. 128) speeds up processing and still produce | |||
an output image of good quality. The output image will have the same | |||
minimum and maximum value as the input image. A clip limit smaller than 1 | |||
an output image of good quality. A clip limit of 0 or larger equal 1 |
mkcor
Jul 17, 2020
Contributor
Is "a clip limit either == 0 or >=1" what is intended?
Is "a clip limit either == 0 or >=1" what is intended?
funkey
Jul 28, 2020
Author
For CLAHE, the clip value would be in the open interval (0, 1). Clip values >=1 essentially disable clipping and therefore simply perform AHE. A clip value of 0 does not really make sense, so the implementation falls back to AHE in this case.
For CLAHE, the clip value would be in the open interval (0, 1). Clip values >=1 essentially disable clipping and therefore simply perform AHE. A clip value of 0 does not really make sense, so the implementation falls back to AHE in this case.
From a cursory glance, I agree with these changes and that the test should be updated. @funkey ( |
I believe the tests are fixed, the CircleCI error seems unrelated to me. Let me know if I can do anything else! |
Thanks for investigating, @funkey! |
Description
Addresses #4827 and fixes docstrings.
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.