Skip to content

[#52] --transparent-background: region-based background removal#56

Merged
realproject7 merged 1 commit into
mainfrom
task/52-transparent-bg
Jun 20, 2026
Merged

[#52] --transparent-background: region-based background removal#56
realproject7 merged 1 commit into
mainfrom
task/52-transparent-bg

Conversation

@realproject7

Copy link
Copy Markdown
Owner

Adds --transparent-background: cut the edge-connected background from a color conversion, leaving a transparent SVG.

  • Reuses the shared _edge_flood_fill_mask ([#53,#51] Region-based bg segmentation: fix solid-bg holes + --background <color> #55) — region-based, not color-based, so a subject sharing the bg color (e.g. light hair) is preserved. Deleting paths by color removed the hair in the earlier manual workaround; this does not.
  • Maps each path into the mask (applying its translate), drops the full-canvas base + paths whose outline is mostly background. Runs after the verify loop, so scoring is unaffected (avoids the rasterize-flattens-alpha gotcha). Color mode only.
  • 97 tests pass + ruff clean. Visually verified on a real chibi illustration (58% transparent, full hair kept).

Closes #52

🤖 Generated with Claude Code

…nt SVG

Reuses the region-based _edge_flood_fill_mask (shared with --solid-background)
to cut the edge-connected background from the final color SVG: each path is
mapped into the mask (applying its translate) and dropped when it covers the
whole canvas or its outline sits mostly in the background. Region-based, so a
subject that shares the background color is preserved (e.g. light hair, unlike
deleting paths by color). Runs after the verify loop, so scoring is unaffected.
Color mode only (binary/pixel line-art is already foreground-only).

Verified on a real chibi illustration: clean transparent cutout, full hair kept.

Closes #52

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@realproject7 realproject7 merged commit 7022867 into main Jun 20, 2026
2 checks passed
@realproject7 realproject7 deleted the task/52-transparent-bg branch June 20, 2026 13:57
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.

feat: --transparent-background — remove the background for a transparent SVG

1 participant