Skip to content

feat(degradations): model paper that is not flat and light that is not even - #15

Open
hBouanane wants to merge 1 commit into
feat/diacriticsfrom
feat/physical-realism
Open

feat(degradations): model paper that is not flat and light that is not even#15
hBouanane wants to merge 1 commit into
feat/diacriticsfrom
feat/physical-realism

Conversation

@hBouanane

Copy link
Copy Markdown
Collaborator

Stacked on #14. Targets the sim-to-real gap that reviewers always attack — realistic scene synthesis reports +8.21 on wild documents from modelling deformation and illumination.

What was missing

OCRSmith modelled flat perspective only. A real capture has a sheet that bends and light that falls unevenly.

New Physical cause
Wrinkles The sheet is displaced locally; its ridges catch light
PageCurl A bound page bends away from the sensor — text compresses toward one edge, the gutter darkens
IlluminationField A lamp or window lights part of the page more than the rest, smoothly

PageCurl produces the single most recognisable artefact of a photographed book page, and flat perspective warping cannot make it. IlluminationField is deliberately distinct from the existing Shadow (a linear ramp) and Vignette (radial, centred) — real lighting is neither.

The part that matters

These displace pixels, so they carry the annotation through the same field. Rather than inverting each field analytically, the displacement is sampled at every box corner — the fields are smooth, so corner sampling tracks the ink, and it generalises to any field without needing a closed form.

Verified by measuring the actual ink extent in the degraded image and requiring the boxes to be there: IoU > 0.85 for both deformations.

Implementation note

Fields are generated at 1/28 scale and upsampled. Paper deformation and lighting are smooth at a scale far larger than a glyph, so a per-pixel field would be both physically wrong and slow. Resampling is nearest-neighbour deliberately: bilinear would soften strokes in a way indistinguishable from a blur degradation, which would confound any ablation.

Verified

522 tests (22 new). The photo and archive presets now use these.

…t even

Rendering-based synthesis produces a page lying perfectly flat under
perfectly uniform light. Real captures never do, and the literature puts the
gap at several points on documents photographed in the wild.

- Wrinkles: local smooth displacement plus the shading its ridges catch.
- PageCurl: a bound page bending away from the sensor, compressing text
  toward one edge and darkening into the gutter - an artefact flat
  perspective warping cannot produce.
- IlluminationField: smooth arbitrary lighting, distinct from Shadow (a
  linear ramp) and Vignette (radial, centred). Real lighting is neither.

The deformations map the annotation through the same displacement field,
sampled at each box corner rather than inverted analytically: the field is
smooth so corner sampling tracks the ink, and it works for any field without
a closed form. Verified by measuring where the ink actually landed and
requiring the boxes to be there.

Fields are generated small and upsampled, because paper deformation and
lighting are smooth at a scale far larger than a glyph - per-pixel would be
both wrong and slow.

Co-Authored-By: Claude Opus 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