Account for the padding shift during vectorization + use multipolygon#921
Merged
melonora merged 6 commits intoscverse:mainfrom May 27, 2025
Merged
Account for the padding shift during vectorization + use multipolygon#921melonora merged 6 commits intoscverse:mainfrom
melonora merged 6 commits intoscverse:mainfrom
Conversation
for more information, see https://pre-commit.ci
…tialdata into fix_vectorize
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #921 +/- ##
==========================================
- Coverage 92.11% 92.09% -0.02%
==========================================
Files 48 48
Lines 7429 7430 +1
==========================================
Hits 6843 6843
- Misses 586 587 +1
🚀 New features to boost your workflow:
|
Member
|
Thanks for the PR! I leave my review. |
LucaMarconato
approved these changes
May 5, 2025
Member
|
If you agree on my changes we can merge. |
Contributor
Author
|
Thanks @LucaMarconato, your change looks good! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
_vectorize_mask, we pad the mask before usingfind_contours, which is needed to have correct geometries. Yet, it create a shift of one pixel in the coordinates.This PR shifts the geometry of one pixel to recover the original coordinates. In the test that I added, when doing rasterize + vectorize, we now have an IoU of 0.98 instead of 0.92.
When one label has multiple geometries, I now use a MultiPolygon instead of multiple Polygon. This is more convenient and less ambiguous, as we'll have only one row per label from the mask.