Skip to content
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

Fix bug in SLIC superpixels with enforce_connectivity=True and start_label > 0 #6242

Merged
merged 4 commits into from
Feb 14, 2022

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Feb 9, 2022

Description

closes #6240

Prevent possible 0 label in output when start label > 0 for SLIC superpixels. This could occur when running "_enforce_label_connectivity_cython" because the adjacent variable started with value 0, but it seems like it must start with current_new_label (or start_label) to avoid potentially assigning a value outside the label range.

This is only really an issue at the upper edge/corner of the image where it is possible that adjacent never gets assigned because there are not yet any adjacent labels assigned to pull from.

Checklist

  • Docstrings for all functions
  • Gallery example in ./doc/examples (new features only)
  • Benchmark in ./benchmarks, if your changes aren't covered by an
    existing benchmark
  • Unit tests
  • Clean style in the spirit of PEP8
  • Descriptive commit messages (see below)

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • There is a bot to help automate backporting a PR to an older branch. For
    example, to backport to v0.19.x after merging, add the following in a PR
    comment: @meeseeksdev backport to v0.19.x
  • To run benchmarks on a PR, add the run-benchmark label. To rerun, the label
    can be removed and then added again. The benchmark output can be checked in
    the "Actions" tab.

previously it was possible for adjacent to not be assigned leading to
occasional outputs with regions labeled as 0 when start_label is > 0
@grlee77 grlee77 added 🩹 type: Bug fix Fixes unexpected or incorrect behavior backport: 0.19.x labels Feb 9, 2022
@grlee77 grlee77 added this to the 0.19.2 milestone Feb 9, 2022
Copy link
Member

@rfezzani rfezzani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @grlee77, LGTM 😉

@grlee77 grlee77 merged commit 4cd351a into scikit-image:main Feb 14, 2022
@grlee77
Copy link
Contributor Author

grlee77 commented Feb 14, 2022

@meeseeksdev backport to v0.19.x

meeseeksmachine pushed a commit to meeseeksmachine/scikit-image that referenced this pull request Feb 14, 2022
…rce_connectivity=True` and `start_label > 0`
grlee77 added a commit that referenced this pull request Feb 14, 2022
…2-on-v0.19.x

Backport PR #6242 on branch v0.19.x (Fix bug in SLIC superpixels with `enforce_connectivity=True` and `start_label > 0`)


def test_start_label_fix():
"""Tests the fix for a bug producing a label < start_label (gh-6240).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Tests the fix for a bug producing a label < start_label (gh-6240).
"""Test the fix for a bug producing a label < start_label (gh-6240).

Sorry for coming late! Thanks for adding this test 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🩹 type: Bug fix Fixes unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible error in SLIC with the start_label parameter
3 participants