-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Wrong threshold value in threshold_otsu when passing a precomputed histogram #5496
Comments
maurosilber
added a commit
to maurosilber/scikit-image
that referenced
this issue
Aug 2, 2021
When the histogram started with zero count bins, a divide by zero happened at thresholding.py:351, yielding np.nan values. Then, at line 359, np.argmax returned 0 as index, producing a wrong threshold value. Closes scikit-image#5496.
maurosilber
added a commit
to maurosilber/scikit-image
that referenced
this issue
Aug 2, 2021
maurosilber
added a commit
to maurosilber/scikit-image
that referenced
this issue
Aug 3, 2021
maurosilber
added a commit
to maurosilber/scikit-image
that referenced
this issue
Aug 3, 2021
`thresholding.validate image_histogram` computes histograms with `exposure.histogram(..., source_range='image')`, which determines the histogram range from the input. Instead, an histogram precomputed with `numpy.bincount` might return an array that start with zeroes. Supplying such histogram cause issues in `thresholding.threshold_otsu` (issue scikit-image#5496). Trimming user-supplied histograms if the array of counts starts or ends with zeros, provides the same output histogram as if the image itsef was provided (in case of integer dtypes).
maurosilber
added a commit
to maurosilber/scikit-image
that referenced
this issue
Aug 3, 2021
`thresholding.validate image_histogram` computes histograms with `exposure.histogram(..., source_range='image')`, which determines the histogram range from the input. Instead, an histogram precomputed with `numpy.bincount` might return an array that start with zeroes. Supplying such histogram cause issues in `thresholding.threshold_otsu` (issue scikit-image#5496). Trimming user-supplied histograms if the array of counts starts or ends with zeros, provides the same output histogram as if the image itsef was provided (in case of integer dtypes).
rfezzani
pushed a commit
that referenced
this issue
Aug 4, 2021
* Added threshold_otsu test for #5496 * Fix validate_image_histogram when hist starts/ends with zeroes `thresholding.validate image_histogram` computes histograms with `exposure.histogram(..., source_range='image')`, which determines the histogram range from the input. Instead, an histogram precomputed with `numpy.bincount` might return an array that start with zeroes. Supplying such histogram cause issues in `thresholding.threshold_otsu` (issue #5496). Trimming user-supplied histograms if the array of counts starts or ends with zeros, provides the same output histogram as if the image itsef was provided (in case of integer dtypes).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When the histogram has bins with zero counts at the beginning, it returns zero as threshold.
Way to reproduce
Version information
The text was updated successfully, but these errors were encountered: