Skip to content

Add --symmetric flag for confidence-based horizontal symmetry enforcement#20

Open
marksverdhei wants to merge 1 commit into
mainfrom
feature/symmetric-enforcement
Open

Add --symmetric flag for confidence-based horizontal symmetry enforcement#20
marksverdhei wants to merge 1 commit into
mainfrom
feature/symmetric-enforcement

Conversation

@marksverdhei
Copy link
Copy Markdown
Owner

Summary

  • Add enforce_symmetry() function to utils.py that enforces horizontal symmetry using confidence-based consensus
  • Add -s/--symmetric CLI flag to enable symmetry enforcement during processing
  • Add 9 comprehensive unit tests for the symmetry feature

Motivation

AI-upscaled pixel art often has minor asymmetries from anti-aliasing artifacts. This feature allows users to automatically fix these by picking the "more confident" pixel from each mirror pair, where confidence is based on saturation and distance from middle gray.

How it works

For each pair of horizontally mirrored pixels that differ:

  1. Calculate confidence score = saturation + |brightness - 128|
  2. Transparent pixels get confidence = 0
  3. The pixel with higher confidence wins for both positions

Test plan

  • All 16 tests pass (7 existing + 9 new symmetry tests)
  • Tested manually with AI-upscaled sprite images
  • Verified symmetric input remains unchanged
  • Verified asymmetric input becomes symmetric

🤖 Generated with Claude Code

…ment

Adds a new -s/--symmetric CLI flag that enforces horizontal symmetry
on the output image using confidence-based consensus. This is useful
for symmetric pixel art sprites that have minor asymmetries from AI
upscaling artifacts.

How it works:
- Calculate confidence for each pixel based on saturation and distance
  from middle gray (128, 128, 128)
- For each pair of horizontally mirrored pixels, if they differ, pick
  the higher-confidence pixel for both positions
- Transparent pixels have zero confidence and defer to opaque pixels

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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