Skip to content

Fix hairline tails and stray blobs in section segmentation masks - #31

Open
hannalee2 wants to merge 7 commits into
feat-web-uifrom
bugfix-seg-hairline
Open

hannalee2 wants to merge 7 commits into
feat-web-uifrom
bugfix-seg-hairline

Conversation

@hannalee2

Copy link
Copy Markdown
Collaborator

Problem

Cropped section images showed thin one-pixel lines ending in small blobs, and narrow bridges to neighbouring fragments. They showed up in the segmented output.

Cause

Results.masks.xy builds its polygons with ops.masks2segments(), and its default strategy is "all". When a mask has several disconnected pieces (the section plus a debris fragment or a neighbouring section), "all" joins every contour into one polygon with thin connecting lines (merge_multi_segment). fillPoly in post_processing.py then kept the connectors and stray pieces in the crop.

Checked against Ultralytics 8.4.54:

Changes

  • Build each section polygon from the raw binary mask (_largest_polygon), keeping only the largest contour by area, so connectors and stray pieces are dropped.
  • Open the mask with a small kernel to remove spurs and thin bridges. The kernel size is the new yolo.mask_open_kernel setting (default 3, 0 disables), added to the YAML, the QC schema and the web schema.

Example)
00019_section_0 - Copy (Before)

00019_section_0 (After)

Section crops showed thin lines ending in small blobs, and narrow bridges to neighbouring fragments.
Cause: Results.masks.xy builds polygons with ops.masks2segments(), whose default strategy 'all' joins every disjoint contour mask into one polygon using thin connecting line.

This branch was successfully deployed

1 active deployment
github-pages — 22282660 Deployed Oct 21, 2026 by hannalee2 via docs / deploy-docs #43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant