Skip to content

Fix morphology.flood for F-ordered images - #4556

Merged
sciunto merged 2 commits into
scikit-image:masterfrom
lagru:fix-flood-forder
Apr 5, 2020
Merged

sciunto merged 2 commits into
scikit-image:masterfrom
lagru:fix-flood-forder

Conversation

@lagru

@lagru lagru commented Apr 5, 2020

Copy link
Copy Markdown
Member

Description

Fixes #4549. Previously flood wouldn't work with f-orderded images. This add's missing "order" parameters to flood and introduces the same parameter to _fast_pad.

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.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

Add missing "order" parameters and introduce the same parameter to
_fast_pad. Previously flood wouldn't work with f-orderded images.
@lagru lagru added the 🩹 type: Bug fix Fixes unexpected or incorrect behavior label Apr 5, 2020

@rfezzani rfezzani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Excellent, concise test... well done 👍 Thank you @lagru

@sciunto sciunto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor changes on my side. Thanks @lagru

Comment thread skimage/morphology/extrema.py Resolved
Comment thread skimage/morphology/extrema.py Resolved
Comment thread skimage/morphology/_flood_fill.py Resolved
Co-Authored-By: François Boulogne <[email protected]>
@sciunto
sciunto merged commit e58cead into scikit-image:master Apr 5, 2020
@lagru

lagru commented Apr 5, 2020

Copy link
Copy Markdown
Member Author

Thanks for the quick reviews and suggestions.

@lagru
lagru deleted the fix-flood-forder branch April 5, 2020 17:03
lagru added a commit to lagru/scikit-image that referenced this pull request Apr 8, 2020
_fast_pad was changed on master in
e58cead
while it was moved on this branch.
rfezzani pushed a commit that referenced this pull request Apr 9, 2020
* Move shared nd-utility functions into _util module

* Simplify/tweak helper functions in morphology._util

Simplify construction of indices, use consistent name for structuring
element (selem), some reformatting and improve documentation.

* Support raveled offsets for dimensions smaller selem

The old implementation would raise a ValueError if a dimension length
given in `image_shape` was smaller than in `selem`. This precluded
operations on images e.g. with the shape (2, 100).

* Address unintended reorering by np.unique

* Check dimensions _offsets_to_raveled_neighbors

* Enhance docstrings and examples

which may act as lightweight tests.

* Add test for _offsets_to_raveled_neighbors

* Add explicit _offsets_to_raveled_neighbors tests

The explicit tests are meant to catch subtle changes in the order of
neigbors with the same connectivity. They were reviewed by constructing
an image of the given shape and filling in the raveled image around the
image center and manual inspection of the result. E.g. with

    image = np.zeros(image_shape)
    image_raveled = image.ravel()
    image_center = tuple(s // 2 for s in image_shape)
    image_center_raveled = np.ravel_multi_index(
        image_center, image_shape
    )
    for i, offset in enumerate(offsets):
        index = image_center_raveled + offset
        assert image_raveled[index] == 0
        image_raveled[index] += i + 1

* Remove morphology._fast_pad once NumPy >= 1.17

* Add tweaks on morphology._util and testing

* Rename to _set_border_values

"edge" may be associated with "edge filters" while "border" is used
throughout the library already.

* Flatten test suite in test_util

* Manually port changes to _fast_pad from #4556

_fast_pad was changed on master in
e58cead
while it was moved on this branch.

* Improve formatting and error messages
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.

skimage.morphology.flood bug with F-ordered Numpy Arrays

3 participants