Propose the content rectangle from the staff lines
Both scan problems reported from testing came from the same place: the content rectangle defaulted to the whole page, so the mechanism meant to handle margin junk never engaged. Ketun joululaulu has a vertical scan streak down the right margin and Engel a shadow, and because trim is tight and per slice, either one sets that slice's width, which sets the song's widest slice, which scales the whole song down. Detection can propose it. Staff lines are long horizontal runs; scan shadows, spine darkening and glass streaks are vertical, so a wide flat opening keeps one and erases the other. Three corrections were needed against the corpus: - Search only rows inside detected systems. A horizontal artefact above or below the music is itself a long horizontal run reaching the paper edge, which put Engel's left bound at 0. - Take a percentile of the staff-line extents, not the maximum. Where an artefact touches a staff line the two merge into one component: on Ketun p2 the merged line ends at 1575px against 1544px on the clean page. - Take the left bound from the brackets too. A bracket sits left of every staff line, so a staff-line bound crops it off — visible immediately when comparing exported slices. Anchors are now a dataclass carrying their left edge rather than a (top, bottom) tuple. Engel now drops 12-14% of page width and its music fills 1920px instead of leaving the shadow's dead space; Ketun drops 12%. Existing projects keep their saved rectangle; the editor's new Auto-fit and Auto-fit all buttons re-propose it without disturbing cuts.
This commit is contained in:
@@ -170,6 +170,9 @@ class Project:
|
||||
skew=detection.skew,
|
||||
cuts=[Cut.straight(y / height) for y in ys],
|
||||
discards=discards,
|
||||
# Per page, not per song: scans drift, so the margin junk
|
||||
# sits in a different place on each one.
|
||||
content_rect=detection.content,
|
||||
)
|
||||
)
|
||||
return cls(source=source, source_hash=hash_file(source), pages=pages)
|
||||
|
||||
Reference in New Issue
Block a user