tetrak_ocr.orientation¶
Which way up a page is, read from the ink, and the turn that rights it.
Scans come in on their side or on their head – microfilm frames shot however the pages lay, a postcard turned on the glass – and nothing in the file says so. This reads it from the picture, deterministically and with no model, in two questions asked in order:
Is there text, and do its lines run across or down? The page is cut into a grid, and in each block holding textured ink the variance of the row sums is set against the variance of the column sums: lines of text make one peaky and the other flat. The median over the blocks decides, so a gutter or a page edge that fools a few blocks does not carry the page. This works for any script (design research 002: 220 of 221 Armenian pages clear the threshold). It is measured at 2000 px on the long side; at full resolution the column profile starts to resolve letter strokes and the ratio shrinks.
With the lines across, which way is up? This depends on the script, which is why the caller names it rather than leaving it to be guessed:
Latin: more ink sits above a line’s body (ascenders, capitals, dots) than below it (descenders), so the share of a line’s outer ink lying above it is well over a half upright and well under on its head. It does not hold for Armenian, whose letters put as much ink below the line as above it (design research 002).
Armenian: which way the open sides of the letters face, after Aradhye (2005). Background enclosed by a letter’s ink on three sides and open upward (the bowl of ս) outweighs that open downward (the arch of ո) in every Armenian face measured: 18 registers, every text page right both ways up (design research 003). The same measure is poor on Latin print and no better than a coin on handwriting.
Both want detail, so they are measured at up to 4000 px (design research 002, finding 4).
Unsure means untouched. Turning a correct page upside down is worse than
leaving a wrong one alone, so a page is turned only when both answers are
clear; otherwise Orientation says why not, for a person to check.
The margins below come from the studies’ saved per-page readings, not from
judgement: inside them, every reading the studies called wrong falls.
The Latin measures were written for the Empire on Trial reading site and are carried here with its two corrections: adjacent maxima in a typeset line’s profile are merged before a line is judged, and an up-share resting on fewer than half the lines the finder saw is not trusted.
Module Attributes
|
The scripts whose up/down measure has been measured. |
Functions
|
How many degrees clockwise turn image upright, for a page in script. |
|
Fail now, not on the first page, if script cannot be measured here. |
|
Rotate clockwise by a multiple of 90 degrees. |
|
The file to read for path, turned upright if it needs it. |
Classes
|
What was read from one page, and the turn that rights it. |