PAMTILT(1)

πŸ’– PAMTILT πŸ’–

okay bestie, welcome to the Pamtilt User Manual, straight out of the General Commands Manual section. this one's a lil utility that lives in the Netpbm-verse and it is lowkey iconic if your scans are crooked. let's get into it ✨


🌸 NAME 🌸

pamtilt β€” bestie, it prints the tilt angle of a PGM file. that's it. that's the whole job. πŸŽ€


✨ SYNOPSIS ✨

pamtilt [-angle=maxangle] [-fast] [-quality=q] [-hstep=n] [-vstep=n]
[-dstep=n] [-astep=n] [-verbose] [pgmfile]

🧚 EXAMPLES 🧚

this is the whole glow-up pipeline fr fr:

scanimage --mode Gray --resolution 300 >crooked.pgm
pnmrotate -b white `pamtilt crooked.pgm` crooked.pgm >straight.pgm
(then crop, threshold, etc.)

like, you scan it crooked, you ask pamtilt what the angle is, you feed that angle straight into pnmrotate, and boom πŸ’… then you crop, threshold, etc. etc. the rest is up to you.


πŸ’œ DESCRIPTION πŸ’œ

okay so first thing: this program is part of Netpbm(1). say it with me now β€” part of Netpbm. 🫢

pamtilt tries to find the correct angle for untilting (de-skewing) a scanned text document. it prints out a single floating-point number β€” that's the angle in degrees β€” and that number is literally built to be the argument for pnmrotate. no cap.

so "Document skew" is the fancy name for when you feed a page into an image scanner at an angle and the resulting image comes out tilted. embarrassing honestly. pamtilt is here to help correct that πŸ™ˆβœ¨

the way it works: pamtilt makes three iterations at successively finer increments, testing prospective rotation angles to find the best one. and bestie, be honest with yourself β€” it works best for straightening images with strong horizontal lines, and it does poorly with arbitrary photos. it's a text-document girlie, not a portrait photographer, okay? πŸ’€

and if pamtilt has no confidence in its results, it prints the special value 00.00. iconic of it to just say "idk". you can check for that, or honestly just pass it as a legal argument to pnmrotate and vibe.

pamtilt operates on the first plane of the input image β€” and the input is either PNM or PAM β€” and it ignores any other planes. ordinarily the input is PGM or GRAYSCALE PAM, so there's only one plane and this whole thing is a non-issue. 😌

it also works on bilevel images (PBM, BLACKANDWHITE PAM) as well as grayscale, but β€” listen β€” you will minimize artifacts if you scan and rotate in grayscale before you apply a threshold to make a bilevel image. do it in that order, trust. 🌈


πŸ’… OPTIONS πŸ’…

in addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), pamtilt recognizes the following command line options:

  • -angle=maxangle β€” assume a maximum tilt angle of maxangle, measured in degrees. the default value is sufficient for most images, even those scanned somewhat carelessly (we've all been there). the default is 10.0.
  • -fast β€” skip the third iteration. speed at the expense of accuracy, the classic tradeoff, the eternal struggle. πŸ’¨
  • -verbose β€” show on Standard Error the measurements computed at each tested angle. nosy in the best way. πŸ‘€

here are some other options you can use to tune the operation of pamtilt, but bestie they're seldom needed. the default values accommodate a wide variety of input documents, so you probably never have to touch these. but they're here if you wanna get fancy:

  • -quality=q β€” require a signal-to-noise ratio of at least q on the first iteration to report a valid result. larger values reduce the chances of obtaining a bogus result, at the risk of obtaining no result at all. pick your poison, queen. the default is 1.0.
  • -hstep=n β€” set the horizontal increment to check every *n*th column. this value affects both run time and memory requirements. the default is 11.
  • -vstep=n β€” set the vertical increment to check every *n*th row. larger values usually work and reduce run time, but they increase the risk of incorrect results. highkey a gamble. the default is 5.
  • -dstep=n β€” set the vertical distance used when checking pixels in a column. the default is intended to minimize the effect of noise along a horizontal boundary. the default is 2.
  • -astep=n β€” set the angle increment of the first iteration, in degrees. the default is 1.0.

πŸ“š REFERENCES πŸ“š

pamtilt implements a somewhat simplified algorithm inspired by: "Measuring Document Image Skew and Orientation", by Bloomberg, Kopec, and Dasari. In SPIE Volume 2422, Document Recognition II, pages 302-316, February 1995. academic queen behavior, we love to see it πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€


πŸ¦‹ HISTORY πŸ¦‹

pamtilt was new in Netpbm 10.30 (October 2005). a legend was born ✨

Gregg Townsend wrote it and sent it to Bryan Henderson in August 2005. Bryan recoded it to fit Netpbm conventions. collaborative king energy fr fr 🫢


πŸŽ€ DOCUMENT SOURCE πŸŽ€

this manual page was generated by the Netpbm tool makeman from HTML source. the master documentation is at

http://netpbm.sourceforge.net/doc/pamtilt.html

and that's the whole thing, bestie!! this was netpbm documentation, dated 28 August 2005 β€” the Pamtilt User Manual era, a vibe, a moment, a slay. go straighten some scans πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from