12.07.2015 Views

A new method for perspective correction of document images

A new method for perspective correction of document images

A new method for perspective correction of document images

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

where a ∣y1 0 y1 1 y12y2 0 y2 1 y22y3 0 y3 1 y32∣ ∣∣∣∣∣ 1 1 1∣ ,b y2 0 y2 1 y22y3 0 y3 1 y32∣ ∣∣∣∣∣ 1 1 1∣ ,c − y1 0 y1 1 y12y3 0 y3 1 y32∣ ∣∣∣∣∣ 1 1 1∣ , and d y1 0 y1 1 y12y2 0 y2 1 y22∣ .3.3 Recovering the coordinates <strong>of</strong> the corners on the original <strong>document</strong> planeAs it was mentioned in Sect. 2, the origin <strong>of</strong> the coordinates system <strong>of</strong> the original <strong>document</strong> plane will belocated at a corner <strong>of</strong> the <strong>document</strong>, that we will choose, without loss <strong>of</strong> generality, to be x 0 , where x denotesthe estimate <strong>of</strong> ¯x, and its axes will be aligned with the <strong>document</strong> edges. There<strong>for</strong>e, in order to estimate theoriginal <strong>document</strong> plane coordinates x, we will move the origin <strong>of</strong> the three-dimensional coordinates systemdescribing y and then rotate the <strong>new</strong> coordinates system until achieving a system such that x 0 = 0, and the<strong>document</strong> edges are aligned with the X and Y axes. Mathematically, we will denote by u i the translated version<strong>of</strong> y i , so D −y 0 · (y i ,1 ) T (= ui1 ,u i 2,u i 3,1 ) T, whereD −y 0 ⎛⎜⎝1 0 0 −y 0 10 1 0 −y 0 20 0 1 −y 0 30 0 0 1Then, we will compute three rotation matrices, namely R X (α), R Y (β) and R Z (γ), around the axes X, Yand Z, according to the angles α, β and γ, such that they translate the points u i onto the XY plane, and withthe edges <strong>of</strong> the <strong>document</strong> aligned with the Cartesian axes. These matrices are defined as⎛R X (α) = ⎝1 0 00 cos α sinα0 −sin α cos α⎞⎛⎠ ,R Y (β) = ⎝cos β 0 −sin β0 1 0sin β 0 cos β⎞⎟⎠ .⎞⎛⎠ , andR Z (γ) = ⎝cos γ sin γ 0−sin γ cos γ 00 0 1The first rotation matrix to be used will be R Z (γ). We will denote the point coordinates in the <strong>new</strong> coordinatesystem by v, so v i = R Z (γ)u i . Then, R Z (γ) will ( be calculated so that the rotated version <strong>of</strong> u 1 , i.e. v 1 , verifiesv 1 2 = 0. There<strong>for</strong>e, γ will be given by γ = arcsinu 1 2 q(u11 ) 2 +(u 1 2) 2 ), which is always properly defined, except whenu 1 1 = u 1 2 = 0; ∗ nevertheless, in that case the original point u 1 already lies on the plane u 1 2 = 0, so the soughttrans<strong>for</strong>mation is not required, and γ = 0.The next rotation we look <strong>for</strong> is R Y (β). The point coordinates in the <strong>new</strong> coordinate system will be denotedby w, so w i = ( R Y (β)v i . In this case, R Y (β) will be derived in order to yield w3 1 = 0, so β will be computed asβ = −arcsinv 1 3 q(v11 ) 2 +(v 1 3) 2 ), which is also properly defined, except <strong>for</strong> the case v 1 1 = v 1 3 = 0; as it happenedwhen defining γ, in this degenerate case this rotation is not necessary, so β = 0.The last rotation, R X (α), will ( translate the rotated version <strong>of</strong> w 3 to the XY plane. This implies that αwill be computed as α = arcsinw 3 3 q(w32 ) 2 +(w 3 3) 2 ), where, as it happened in the two previous cases, the angle isproperly defined as long as w 3 2 = w 3 3 = 0 is not met; if that condition were indeed verified, then this last rotationwould not be required, and α = 0.3.4 Recovering the original <strong>document</strong> plane coordinates <strong>of</strong> an arbitrary <strong>document</strong> pointUp to this point, we have only operated over the corners <strong>of</strong> the <strong>document</strong>. Nevertheless it is possible to generalizethe obtained results to any point belonging to the possibly isotropically scaled version <strong>of</strong> the <strong>document</strong>. Indeed,by definingG (RX (α) R Y (β) R Z (γ) 00 T 1)· D −y0 ,∗ Throughout this paper we will assume that arcsin(·) ∈ [−π/2, π/2], and consequently the related cos(·) will benon-negative.⎞⎠ .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!