No description
Find a file
scarlet d968a23236 feat(bbox): grid-driven layout flow, retiring flood-fill (#8)
Reworks the layout/OCR stage (Stage 1) into a coarse→fine **grid flow** that reads coordinates off a pixel-labelled grid instead of flood-fill mask measurement. One method that works identically for speech bubbles, borderless text, and sfx — and geometry is separated from transcription.

## `scripts/v0_bbox.py` — five subcommands

| phase | cmd | role |
|---|---|---|
| 1–2 locate | `grid` / `view` | overview finds regions; `view` window is the *placement surface* (100px snap) |
| 3 refine | `refine` (fanout) | per-bbox 3× tighten to pixels; re-run to confirm; also a validator |
| 4 transcribe | `zoom` | clean gridless upscale; `jp` enters here |
| 5 gate | `final` | typed overlay + `--missing`; read against raw for completeness |

## Pipeline wiring

- New agent **`bbox-locator`** replaces `layout-verifier` — it *builds* the region list from scratch via the grid flow rather than verifying pre-existing regions.
- `SKILL.md` Stage 1 rewritten; new `bbox-agent-prompt.md` (thin task template) + `bbox-workflow.md` (operational spec, phases 1–5).
- **`v0_annotate.py` untouched** — the typesetter still uses `--flood`, QC still uses `--crop`. Flood-fill only lost its layout-stage role.
- **JSON interface is unchanged** (`regions` + `layout_verified`), so Stages 2–10 need no changes.

## Why

Flood-fill only worked on clean closed outlines — it leaked on broken bubbles and did nothing for borderless text or sfx, so the agent eyeballed anyway and burned tokens tuning seed/threshold. The grid gives the model a coordinate frame it can actually read.

## Worked example — RJ379854 p24 (sfx-heavy, clean-room)

Layered validation caught **3 over-tagged motion marks** (culled at refine/zoom) and **1 mislocated sfx** (caught by the phase-5 gate) before any reached cleaning, where a false `sfx` is destructive. `page_0024.json` is included as the example (layout not finalized — bottom-tier sfx still queued for transcription).

Rationale and per-phase learnings are recorded in `LESSONS.md` (2026-07-23).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: schattenan <schattenan@kagaku.eu>
Reviewed-on: #8
Co-authored-by: scarlet <scarlet@kagaku.eu>
Co-committed-by: scarlet <scarlet@kagaku.eu>
2026-07-23 21:39:00 +02:00
.claude feat(bbox): grid-driven layout flow, retiring flood-fill (#8) 2026-07-23 21:39:00 +02:00
inbox inbox/ drop folder: tracked entry point for pasting raw pages 2026-07-21 19:28:58 +02:00
knowledge v0: agent-first translation pipeline, translate-chapter skill, RJ379854 ch001 2026-07-21 18:47:49 +02:00
scripts feat(bbox): grid-driven layout flow, retiring flood-fill (#8) 2026-07-23 21:39:00 +02:00
works/RJ379854 feat(bbox): grid-driven layout flow, retiring flood-fill (#8) 2026-07-23 21:39:00 +02:00
.gitignore feat(bbox): grid-driven layout flow, retiring flood-fill (#8) 2026-07-23 21:39:00 +02:00
CLAUDE.md fix: address review — move to .claude/feedback/, add Edit tool, lean prompts 2026-07-22 15:43:54 +00:00
LESSONS.md feat(bbox): grid-driven layout flow, retiring flood-fill (#8) 2026-07-23 21:39:00 +02:00