Saliency-based smart crop #2

Merged
zyberzero merged 5 commits from smart-crop into main 2026-11-03 18:12:20 +00:00
Owner

Summary

  • Replace the center-crop cover resize with a Sobel edge-density smart crop (SaliencySmartCropper). The pipeline crops to the target aspect, then does a pure resize. Same-aspect inputs skip the crop entirely, and any error falls back to the centered crop with a warning.
  • Search only the max-fitting window. The 85% and 70% candidate sizes could never outscore the full-size window containing them, because edge energy is never negative. Always check the last x/y position so subjects at the right or bottom edge aren't cut off.
  • Add SaliencySmartCropperTests: it biases toward the edge-heavy side on both axes, reaches the edge for a subject touching it, and returns an in-bounds rect at the target aspect. Add the asymmetric-edges golden fixture and regenerate the existing goldens.
  • Update SPEC.md §3.2, PLAN.md and IMPLEMENTATION.md, and tick the MQTT auto-reconnect increment that landed in #1.

Test plan

  • dotnet test: 185/185 pass
  • Smoke test: upload a 16:9 photo to a 4:3 frame and check the subject is kept

🤖 Generated with Claude Code

## Summary - Replace the center-crop cover resize with a Sobel edge-density smart crop (`SaliencySmartCropper`). The pipeline crops to the target aspect, then does a pure resize. Same-aspect inputs skip the crop entirely, and any error falls back to the centered crop with a warning. - Search only the max-fitting window. The 85% and 70% candidate sizes could never outscore the full-size window containing them, because edge energy is never negative. Always check the last x/y position so subjects at the right or bottom edge aren't cut off. - Add `SaliencySmartCropperTests`: it biases toward the edge-heavy side on both axes, reaches the edge for a subject touching it, and returns an in-bounds rect at the target aspect. Add the `asymmetric-edges` golden fixture and regenerate the existing goldens. - Update SPEC.md §3.2, PLAN.md and IMPLEMENTATION.md, and tick the MQTT auto-reconnect increment that landed in #1. ## Test plan - [x] `dotnet test`: 185/185 pass - [x] Smoke test: upload a 16:9 photo to a 4:3 frame and check the subject is kept 🤖 Generated with [Claude Code](https://claude.com/claude-code)
zyberzero added 5 commits 2026-11-03 18:08:37 +00:00
Replace the center-crop cover resize with a Sobel edge-density search
that picks the target-aspect window with the most edge energy, so a
subject off-center isn't sliced when the input aspect differs from the
frame's. Failures fall back to the centered crop. Golden fixtures are
regenerated and an asymmetric-edges input exercises the bias.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Edge energy is non-negative, so the 85% and 70% candidate windows could
never outscore the full-size window containing them; drop them. Also
always evaluate the last x/y position so a subject touching the right
or bottom edge isn't cut by up to one step of grid misalignment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The golden fixtures only prove determinism; these assert the crop
actually biases toward the edge-rich side on both axes, reaches the
source edge for an edge-hugging subject, and always returns an in-bounds
rect at the target aspect.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Landed in #1 but the checkbox was never ticked.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
zyberzero merged commit 9fd4e78065 into main 2026-11-03 18:12:20 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: zyberzero/frame-processor#2