Esa Kataja 6ff956a622 Add detection: skew, system anchors, ink extents, cuts, staff height
Systems anchor on the vertical bracket and expand over nearby ink, per
ADR 0006. Two corrections the corpus forced:

- Expansion measures distance from the bracket, never from the growing
  extent. A chaining expansion hops between the closely-stacked lines of
  a title block and walks the whole way up the page — on Engel p1 it
  swallowed the title into system 1 and the copyright footer into
  system 3.
- Reach is 1.5 staff heights, which takes in the lyrics below the last
  staff and the tempo mark and INTRO box above the first, while leaving
  the title block and footer out.

Verified against the corpus. Ketun joululaulu: 2 systems per page except
p7 (3) and p12 (1), staff 48px throughout, skew -2.7 to +1.2 per page,
and p2 system 1 spans 179-1071 where its bracket is 177-994 — the
difference being the bottom voice's lyric line. Engel: 2-3 systems per
page, staff 70-72px. Elaman nalka: 3 systems per page, 0 skew, staff
118px at 600 DPI.

The overlay dump is what made both bugs visible, and stays as the tool
for diagnosing a page that comes out wrong.

Closes #4, #5, #6, #7, #8, #9
2026-07-28 22:38:50 +03:00

noteman-slicer

Turns a score PDF into the ordered slice images noteman consumes, plus the navigation markers that sit on them.

A slice is one system — one full line of music across all voices, typically 412 bars with lyrics intact. noteman displays them as a continuous vertical scroll, so the slicer's job is to cut a printed page into systems, clean them up enough to read on a tablet, and tag them with the score's navigation symbols.

Status: design only. No code yet. The design is settled; see below.

How it works

Open a PDF, and the tool proposes cuts between systems, a skew correction, and a content rectangle. You correct all of it — source quality varies too much for unattended processing, so detection is an accelerator that nothing depends on being right. You mark the header and footer regions discarded, set black and white points until the paper disappears and the notes go solid, place the rehearsal letters and jump markers, fill in the title block, and export.

Out comes one zip: the slices in order, their markers, the original PDF, and the song metadata. That bundle is the only channel to noteman — there's no API between the two tools.

Erasing previous-owner pencil marks, chord letters and breath marks stays in GIMP. That's the irreducible manual part, and GIMP with a stylus is already good at it.

Installation

Not yet installable. When it is:

uv tool install --editable .

That puts a noteman-slicer command on PATH which runs from any directory — no venv to activate. Dependencies (PyMuPDF, PySide6, OpenCV, numpy) are all wheels; nothing needs a system package.

Documentation

CONTEXT.md Glossary. What a slice, cut, discard, bundle and song scale actually mean here. Start here.
docs/spec.md The specification: pipeline, geometry model, detection, editor, bundle format, and what noteman has to change.

Deferred work is tracked as issues and milestones on the Gitea repo, not in this tree.

Decisions that were expensive to reach, each with the evidence behind it:

ADR 0001 The slicer owns all image processing; the bundle is the only channel to noteman.
ADR 0002 Raster only in release 1 — measured SVG slice sizes and what they showed.
ADR 0003 Lossless WebP beats every lossy option and every alternative format here.
ADR 0004 No unattended mode: detection suggests, a human confirms.
ADR 0005 PyMuPDF for all PDF access, accepting AGPL.
ADR 0006 Systems are found by vertical brackets; row-darkness gaps get it wrong.
S
Description
No description provided
Readme
195 KiB
Languages
Python 100%