How to automatically vertically unshear a scanned page in Debian?
0
votes
0
answers
65
views
Continuing https://unix.stackexchange.com/questions/795046/how-to-automatically-straighten-a-scanned-document-in-debian-linux , how to automatically vertically un-shear a scanned page?
Sometimes a combination of an imprecise printing and an imprecise scanning results in the following layout of the text lines in the resulting image:
You see a vertical shear here. All the text lines go down here; we sometimes see also all the text lines going up. (For privacy reasons, I can't share a real scan here. An artificially created shear can be found in https://ibb.co/DHYWrGYT – it's a shear of page 6 of *The TeXbook* by Donald Erwin Knuth, 2020.)
Out of an image with the above text layout, we'd like to create an image with text lines going horizontally:
The un-shearing has to be done with freely available tools in Debian Linux with the least manual effort; ideally, this would boil down to calling a command that would determine the slope automatically, say,


vertical_shear_fixer scan.png vertically_unsheared_scan.png
. In this question, we assume for simplicity that all the text lines start at the same X value, i.e., that the original scan is not rotated and not horizontally sheared. (Rotating the original scan wouldn't solve the issue: for example, for the image above, rotating counterclockwise could somewhat straighten each text line (or black line) by itself but would introduce a horizontal shear, where the top text lines start more to the left than the bottom text lines; moreover, each letter could look tilted left a tiny bit.) We could start with gray images if it simplifies the matter.
Asked by user743115
(1 rep)
Jul 27, 2025, 02:44 PM
Last activity: Jul 30, 2025, 09:19 PM
Last activity: Jul 30, 2025, 09:19 PM