Skip to content

use_quantiles description in canny is incorrect #4282

Closed

Description

@pigunther

Description

The description of use_quantiles is "If True then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If True then the thresholds must be in the range [0, 1]."

However, he thresholds must be in the range [0, maximum of the image's dtype ]

Way to reproduce

from skimage import data
from skimage.feature import canny
image = data.camera()
edge_canny = canny(image, low_threshold=50, high_threshold=150, use_quantiles=True)
# No error is produced

Cause

This happens because the thresholds are divided by maximum of the image's dtype (lines 163, 168 in _canny.py)

Probable solution

The probable solution is not to divide the thresholds if use_quantiles is True or just simpler change the description.

Version information

# your output here
3.7.3 (default, Sep  5 2019, 17:14:41) 
[Clang 11.0.0 (clang-1100.0.33.8)]
Darwin-19.0.0-x86_64-i386-64bit
scikit-image version: 0.16.2
numpy version: 1.17.3

Activity

  1. jni commented on Nov 5, 2019

    @jni
    Member

    Yikes! Thanks for the report, @pigunther! I think you are right that we should not divide by the dtype max.

  2. added
    ⚠️ Priority
    on Nov 5, 2019
  3. rfezzani commented on Dec 6, 2019

    @rfezzani
    Member

    To fix this issue, I propose in #4342 to add the preserve_range argument and to divide the thresholds only if preserve_range is True.

  4. rfezzani commented on Feb 7, 2020

    @rfezzani
    Member

    A simpler bug fix is proposed in #4437.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚠️ Priority

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions