Skip to content

Canny outputs border artifacts when image is constant with default parameters #6346

Closed

Description

@stefanv

I believe the change occurred in 372b901

The resulting behavior is that the canny edge detector now returns edge pixels on the border of any image that does not have a black background.

This is a change in behavior from previous versions of skimage.

Activity

  1. changed the title [-]Canny mode now implicitly set to `constant`[/-] [+]Canny `mode` now set to `constant` by default[/+] on Apr 18, 2022
  2. stefanv commented on Apr 18, 2022

    @stefanv
    MemberAuthor
    import numpy as np
    import skimage as ski
    
    x = np.ones((10, 10))
    print(ski.feature.canny(x))
    [[False False False False False False False False False False]
     [False  True  True  True  True  True  True  True  True False]
     [False  True False False False False False False  True False]
     [False  True False False False False False False  True False]
     [False  True False False False False False False  True False]
     [False  True False False False False False False  True False]
     [False  True False False False False False False  True False]
     [False  True False False False False False False  True False]
     [False  True  True  True  True  True  True  True  True False]
     [False False False False False False False False False False]]
    

    Desired behavior is achieved by setting mode='reflect'.

  3. grlee77 commented on Apr 18, 2022

    @grlee77
    Contributor

    I think this should just be mode='nearest'. Definitely agree that constant does not seem desirable for this function.

  4. rfezzani commented on Apr 19, 2022

    @rfezzani
    Member

    I believe the change occurred in 372b901

    For clarification, constant was already the default mode before this commit. This commit simply exposes mode and cval in canny API. constant mode was kept for backward compatibility.
    @stefanv, is this a behaviour change or a bug?

  5. stefanv commented on Apr 19, 2022

    @stefanv
    MemberAuthor

    I know the behavior changed, because a tutorial I had written the year before suddenly started malfunctioning, detecting edges on the border.

  6. rfezzani commented on Apr 20, 2022

    @rfezzani
    Member

    I believe the change occurred in 372b901

    @stefanv, you spotted the right commit. I will investigate 😉

  7. rfezzani commented on Apr 20, 2022

    @rfezzani
    Member

    More precisely, here is the exact commit 4c60efe introducing the change!
    I will fix this and add a UT 😉

  8. changed the title [-]Canny `mode` now set to `constant` by default[/-] [+]Canny outputs border artifacts when image is constant with default parameters[/+] on Apr 20, 2022
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions