Skip to content

Add Masks xy and xyn outlines like Ultralytics - #630

Merged
onuralpszr merged 13 commits into
mainfrom
masks-xy
Nov 10, 2026
Merged

onuralpszr merged 13 commits into
mainfrom
masks-xy

Conversation

@onuralpszr

@onuralpszr onuralpszr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Adds Masks::xy() and Masks::xyn() returning the outline of each mask, traced like OpenCV findContours and joined like Ultralytics masks2segments, then scaled to the image like scale_coords, with an example in both READMEs. Builds on #629. All 180 outlines from yolo26n-seg and yolo11n-seg match Python point for point.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Adds Masks::xy() and Masks::xyn() to return mask outlines in image-pixel and normalized coordinates, matching the Ultralytics-style outline workflow.

📊 Key Changes

  • Masks::xy() traces mask pixels above 0.5, keeps external contours, joins multiple contours at their closest points, and maps the points to the original image dimensions.
  • Masks::xyn() normalizes the xy() points by the original image width and height; empty masks return outlines with no points.
  • Makes the postprocessing content-crop calculation available to mask outline scaling and adds a unit test for contour joining, an empty mask, and normalized coordinates.
  • Adds outline usage examples to the English and Chinese READMEs and updates the Rust API documentation.

🎯 Purpose & Impact

  • Users can retrieve segmentation outlines directly from Masks for pixel-coordinate or normalized-coordinate workflows, while the existing mask data remains available.

…ch Python pixel for pixel

Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
…y default like Ultralytics

Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
…ltralytics

Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
…tics scale_coords

Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
@UltralyticsAssistant UltralyticsAssistant added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 10, 2026
@UltralyticsAssistant

Copy link
Copy Markdown
Member

👋 Hello @onuralpszr, thank you for submitting a ultralytics/inference 🚀 PR! This automated message confirms your contribution was received, and an Ultralytics engineer will assist with the review. To ensure a seamless integration of your work, please review the following checklist:

  • ✅ Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • ✅ Synchronize with Source: Confirm your PR is synchronized with the ultralytics/inference main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • ✅ Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • ✅ Update Documentation: Update the relevant documentation for any new or modified features.
  • ✅ Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • ✅ Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR; the CLA check will comment with signing instructions if needed.
  • ✅ Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

@UltralyticsAssistant UltralyticsAssistant 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.

🔍 PR Review

Made with ❤️ by Ultralytics Actions

Reviewed the mask outline APIs, mask resizing and filtering paths, retina-masks configuration, annotation, and documentation. No actionable issues found; LGTM.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.80240% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/results.rs 98.79% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
@onuralpszr
onuralpszr merged commit d24e80a into main Nov 10, 2026
20 checks passed
@onuralpszr
onuralpszr deleted the masks-xy branch November 10, 2026 11:06
@UltralyticsAssistant

Copy link
Copy Markdown
Member

🎉 This PR has been merged—thank you, @onuralpszr! Masks::xy() and Masks::xyn() make it easier to work with segmentation outlines in pixel or normalized coordinates, with tests and README examples to support the new workflow.

“Alone we can do so little; together we can do so much.” — Helen Keller

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

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants