Not So Skewed

Not So Skewed

Straighten a tilted document page with Adaptive Radial Projection on the Fourier Magnitude Spectrum (Pham et al., ICIP 2022). The whole estimator runs in your browser and matches the official jdeskew code angle for angle.

Try an example
Input Skewed
Deskewed Waiting
True skew–counter-clockwise
Detected skew–correction θF
Error–modulo quarter turns
Runtime–in your browser

How the angle is found

The four steps of the method, computed live on the input above. Text lines become a bright line through the centre of the Fourier spectrum; the angle of that line is the skew.

1

Binarize and pad

B
B=T15×15(255−I),B∈{0,1}N×N

Resize to height H, convert to gray, pad with white to an N×N square that the FFT handles fast, then a Gaussian adaptive threshold (C = −10) keeps ink as 1.

2

2D Fourier magnitude

M
M=|shift(F2{B})|

Log-scaled for display. The dashed circle has radius W, the shaded fan is the search range, and the orange ray is the angle being tested.

4

Decide

θF={θa,if |θa−θb|>Dθb,otherwise
θa = argmax A
–
θb = argmax B
–
|θa − θb|
–
Keep θa (correction too far)
Keep θb (correction agrees)

3

Two radial projections

A(θ)=∑s=0RM[cy+scosθ,cx−ssinθ]
B(θ)=∑s=WRM[cy+scosθ,cx−ssinθ]
A(θ), initial projection from the centre B(θ), correction projection from radius W θa ± D Hover the chart to move the ray on the spectrum.

Robustness sweep

Treats the current image as straight, tilts it to 25 known angles across the search range, and scores both estimators with the paper's metrics: average error (AED), share within 0.1° (CE), and worst error (WE).

Not run yet
EstimatorAEDCE (≤ 0.1°)WE
● Initial projection only (jdeskew code)–––
● Adaptive radial projection (paper)–––