1. Field of the Invention
The present invention is related to an image processing technology, and more specifically, to a method of correcting an image with perspective distortion and producing an artificial image with perspective distortion.
2. Description of the Prior Art
When an observer observes a physical object, the observed shape of the physical object is usually slightly different from the original one, which is determined by the distance between the observer and the object and the location of the observer. Such deviation is called perspective distortion.
In the image-processing field, the captured image of a physical object usually suffers from the distortion effect and should be corrected. A conventional correction scheme is described as follows. First, the user needs to locate the four corners of a distorted object on an image, which suffers from the perspective distortion effect. For example, as shown in
However, in the conventional scheme, the user must manually locate the corners of the distorted object and thus determine the corresponding transformation matrix, which is inconvenient for the user.
Therefore, the object of the present invention is to provide a method of processing an image with perspective distortion, which determines the corner coordinates with respect to various distorted sides of a distorted object.
The present invention achieves the above-indicated objects by providing a method of correcting an image with perspective distortion. First, image data including a distorted object image are received. Next, the user inputs an operational instruction for setting a plurality of distortion parameters pertaining to the image data, which include a distorted side of the distorted object image, a central line and a distortion ratio. Thus, a plurality of coordinates of corners of the distorted object image are calculated according to these distortion parameters and a transformation matrix is determined according to the calculated coordinates of the corners of the distorted object image. Finally, the distorted object image is transformed to a corrected object image according to the transformation matrix.
The following detailed description, given by way of example and not intended to limit the invention solely to the embodiments described herein, will best be understood in conjunction with the accompanying drawings, in which:
When these distortion parameters are prepared, the image data 20 is sent to a coordinate-determining unit 40 for determining the coordinates of the corners of the distorted object image and a corresponding transformation matrix. Finally, a transforming unit 50 transforms the distorted object image to an undistorted image according to the transformation matrix. It is noted that an artificial image with perspective distortion can also be produced by a similar process. In the preferred embodiment, all distorted sides of the distorted object image can be sequentially processed by setting different sets of the distortion parameters to determine the required transformation matrix.
The following description focuses on the determination of the coordinates of the corners of the distorted object image. As described above, the distortion side D can be set as TOP, BOTTOM, LEFT and RIGHT. The four cases will be described respectively in details.
The Distortion Side D is TOP (D=TOP)
The coordinates of the corners s, C11t, C12t and r are determined by the known distorted side (D=TOP), the central line C1t and the distortion ratio F. As described above, the coordinates of the corners s and r are (0,H) and (W,H), respectively. The coordinates of the corners C11t and C12t are determined as follows.
With respect to the corner C11t, its y coordinate is the same as the y coordinates of the points p and q, and its x coordinate is calculated by:
C11t,x=x1t−x1t×F (1)
where x1t represents the x coordinate of the central line C1t. The complete coordinates of the corner C11t are obtained.
With respect to the corner C12t, its y coordinate is the same as the y coordinates of the points p and q, and its x coordinate is acquired by using the relationship of the similar triangles shown in FIG. 3.
According to equations (1) and (2), the x coordinate of the corner C12t is calculated by:
where x1t represents the x coordinate of the central line C1t. The complete coordinates of the corner C12t are obtained.
Therefore, the complete coordinates of the four corners r, C11t, C12t and s of the distorted object image are obtained in the first example.
The coordinates of the corners p, C22t, r and C21t are determined by the known distorted side (D=TOP), the central line C2t and the distortion ratio F. As described above, the coordinates of the corners p and r are (0,0) and (W,H), respectively. The coordinates of the corners C21t and C22t are determined as follows.
With respect to the corner C22t, its y coordinate is the same as the y coordinate of the point p (that is, 0), and its x coordinate is calculated by:
C22t,x=x2t+(W+x2t)×F (4)
where x2t is a negative number and represents the x coordinate of the central line C2t. The complete coordinates of the corner C22t are obtained.
With respect to the corner C21t, its y coordinate is the same as the y coordinate of the point s (that is, H), and its x coordinate is calculated as follows. The angle of an extension of the side {overscore (rC22t)} and the central line C2t is defined as θ2t. In addition, the angle of the line segments {overscore (rq)} and {overscore (rC22t)} is also θ2t. According to
Thus, the angle θ2t is obtained by the following equation:
In addition, the length l2t is obtained by the following equation:
where x2t represents the x coordinate of the central line C2t. In addition, since triangles Z2E2p and psC21t are similar, the following equation is satisfied.
The x coordinate of the corner C21t can be determined by equations (5), (6) and (7).
C21t,x=|x2t|×H/[(C22t,x−x2t)cot θ2t] (8)
Accordingly, the complete coordinates of the corner C22t are obtained by equation (4) and the complete coordinates of the corner C21t are obtained by equation (8).
The coordinates of the corners C31t, q, C32t and s are determined by the known distorted side (D=TOP), the central line C3t and the distortion ratio F. As described above, the coordinates of the corners q and s are (W, 0) and (0,H), respectively. The coordinates of the corners C31t and C32t are determined as follows.
With respect to the corner C31t, its y coordinate is the same as the y coordinate of the point q (that is, 0), and its x coordinate is calculated by:
C31t,x=x3t−x3t×F (9)
where x3t represents the x coordinate of the central line C3t. The complete coordinates of the corner C31t are obtained.
With respect to the corner C32t, its y coordinate is the same as the y coordinate of the point s (that is, H), and its x coordinate is calculated as follows. The angle of an extension of the side {overscore (sC31t)} and the central line C3t is defined as θ3t. In addition, the angle of the line segments {overscore (sp)} and {overscore (pC31t)} is also θ3t. As shown in
Thus, the angle θ3t is obtained by the following equation:
In addition, the length l3t is obtained by the following equation:
Since triangles Z3E3q and qrC32t are similar, the following equation is satisfied.
The x coordinate of the corner C32t can be determined by equations (10), (11) and (12).
Accordingly, the complete coordinates of the corner C31t are obtained by equation (9) and the complete coordinates of the corner C32t are obtained by equation (13).
According to the three examples described above, the coordinates of the corners of the distorted object image can be determined by the known distortion parameters when the distortion side is a top side. Subsequently, a new transformation matrix can be obtained and the distorted object image is transformed by means of the transformation matrix.
The Distortion Side D is BOTTOM (D=BOTTOM)
In the first example, the central line is denoted by C1b. The four corners of the distorted object image are denoted by p, q, C11b and C12b, respectively. The coordinates of the two corners C11b and C12b are undetermined. In addition, the other corners p and q and two points r and s constitute four corners of a rectangle, which is illustrated as dash lines, where p=(0,0), q=(W,0), r=(W,H) and s=(0,H). The central line C1b is determined by the intersection Z4 of extensions of the two sides {overscore (pC11b)} and {overscore (qC12b)}. The central line C1b is a line perpendicular to the side {overscore (C11bC12b)} passing through the point Z4, where the intersection of the central line C1b and the side {overscore (C11bC12b)} is E4.
The coordinates of the corners p, q, C11b and C12b are determined by the known distorted side (D=BOTTOM), the central line C1b and the distortion ratio F. As described above, the coordinates of the corners p and g are (0,0) and (W,0), respectively. The coordinates of the corners C11b and C12b are determined as follows.
With respect to the corner C11b, its y coordinate is the same as the y coordinates of the points s and r, and its x coordinate is calculated by:
C11b,x=x1b−x1b×F (14)
where x1b represents the x coordinate of the central line C1b. The complete coordinates of the corner C11b are obtained.
With respect to the corner C12b, its y coordinate is the same as the y coordinates of the points s and r. According to
According to equations (14) and (15), the x coordinate of the corner C12b is calculated by:
where x1b represents the x coordinate of the central line C1b. The complete coordinates of the corner C12b are obtained by equation (16).
The determination of the corner coordinates in the second example, in which the central line is located at the left of the distorted object image, and the third example, in which the central line is located at the right of the distortion object image are similar to those in the first embodiment.
Accordingly, the coordinates of the corners of the distorted object image can be determined by the known distortion parameters when the distortion side is a BOTTOM side. Subsequently, a new transformation matrix can be obtained and the distorted object image is transformed by means of the transformation matrix.
The Distortion Side D is LEFT (D=LEFT)
The central line in the first example is denoted by C1l. The four corners of the distorted object image are denoted by q, r, C12l and C11l, respectively, where the coordinates of C12l and C11l are undetermined. In addition, the two corners s and r and another two points p and q constitute four corners of a rectangle, where p=(0,0), q=(W,0), r=(W,H) and s=(0,H). The central line C1l is determined by the intersection Z7 of extensions of the two sides {overscore (qC11l)} and {overscore (rC12l)}. Thus, the central line C1l is a line perpendicular to the side {overscore (C11lC12l)} passing through the point Z7, where the intersection of the central line C1l and the side {overscore (C11lC12l)} is E7.
The coordinates of the corners q, r, C12l and C11l are determined by the known distorted side (D=LEFT), the central line C1l and the distortion ratio F. As described above, the coordinates of the corners q and r are (W,0) and (W,H), respectively. The coordinates of the corners C11l and C12l are determined as follows.
With respect to the corner C11l, its x coordinate is the same as the x coordinates of the points p and s, and its y coordinate is calculated by:
C11l,y=y1l−y1l×F (17)
where y1l represents the y coordinate of the central line C1l. The complete coordinates of the corner C11l are obtained.
With respect to the corner C12l, its x coordinate is the same as the x coordinates of the points p and s, and its x coordinate is acquired by using the relationship of the similar triangles, which is similar to that in the case of D=TOP.
where y1l represents the y coordinate of the central line C1l. The complete coordinates of the corner C12l are obtained.
Therefore, the complete coordinates of the corner C11l are obtained by equation (17) and the complete coordinates of the corner C12l are obtained by equation (18).
The central line in the first example is denoted by C2l and located above the distorted object image. The four corners of the distorted object image are denoted by p, C21l, r and C22l, respectively, where the coordinates of the two corners C21l and C22l are undetermined. The central line C2l is determined by the intersection Z8 of extensions of the two sides {overscore (C21lp)} and {overscore (rC22l)}. Thus, the central line C2l is a line perpendicular to an extension of the side {overscore (C22lp)} passing through the point Z8, where the intersection of the central line C2l and the extension of the side {overscore (C22lp)} is E8. In addition, the length of the line segment {overscore (E8Z8)} is denoted by l2l.
With respect to the corner C22l, its x coordinate is the same as the x coordinate of the point p (that is, 0) and its y coordinate is calculated by:
C22l,y=y2l+(H−y2l)×F (19)
where y2l is a negative number and represents the y coordinate of the central line C2l.
With respect to the corner C21l, its x coordinate is the same as the x coordinate of the point r (that is, W), and its y coordinate is calculated by the same method shown in FIG. 4.
C21l,y=|y2l|×W/[(C22l,y−y2l)cot θ2l] (20)
where y2l represents the y coordinate of the central line C2l and θ2l is an angle of the line segments {overscore (rC22l)} and {overscore (rs)}. Accordingly, the complete coordinates of the corner C22l are obtained by equation (19) and the complete coordinates of the corner C21l are obtained by equation (20).
The central line in the first example is denoted by C3l and located below the distorted object image. The four corners of the distorted object image are denoted by q, C32l, s and C31l respectively, where the coordinates of the two corners C32l and C31l are undetermined. The central line C3l is determined by the intersection Z9 of extensions of the two sides {overscore (C32ls)} and {overscore (qC31l)}. Thus, the central line C3l is a line perpendicular to an extension of the side {overscore (C31ls)} passing through the point Z9, where the intersection of the central line C3l and the extension of the side {overscore (C31ls)} is E9. In addition, the length of the line segment {overscore (E9Z9)} is denoted by l3l.
With respect to the corner C31l, its x coordinate is the same as the x coordinate of the point s (that is, 0), and its y coordinate is calculated by:
C31l,y=y3l−y3l×F (21)
where y3l represents the y coordinate of the central line C3l.
With respect to the corner C32l, its x coordinate is the same as the x coordinate of the point q (that is, W), and its y coordinate is calculated by the same method shown in FIG. 5.
where y3l represents the y coordinate of the central line C3l and θ3l is an angle of the line segments {overscore (qC31l)} and {overscore (qp)}. Accordingly, the complete coordinates of the corner C31l are obtained by equation (21) and the complete coordinates of the corner C32l are obtained by equation (22)
According to the three examples described above, the coordinates of the corners of the distorted object image can be determined by the known distortion parameters when the distortion side is the left side of the distorted object image. Subsequently, a new transformation matrix can be obtained and the distorted object image is transformed by means of the transformation matrix.
The Distortion Side D is LEFT (D=LEFT)
The process of the determination of the corner coordinates of the distorted object image in this case, in which the distortion side is a left side of the distorted object image, is similar to those in the above cases and will not be described again.
It is noted that the above-described process also can be applied to produce an artificial image with perspective distortion, where the original object image is undistorted.
While the invention has been described by way of example and in terms of the preferred embodiment, it is to be understood that the invention is not limited to the disclosed embodiments. On the contrary, it is intended to cover various modifications and similar arrangements as would be apparent to those skilled in the art. Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements.
Number | Date | Country | Kind |
---|---|---|---|
90104818 A | Mar 2001 | TW | national |
Number | Name | Date | Kind |
---|---|---|---|
5528194 | Ohtani et al. | Jun 1996 | A |
5726716 | Egashira et al. | Mar 1998 | A |
5933132 | Marshall et al. | Aug 1999 | A |
6324297 | Uchida | Nov 2001 | B1 |
6361171 | Ejiri et al. | Mar 2002 | B1 |
6450647 | Takeuchi | Sep 2002 | B1 |
6511185 | Gananathan | Jan 2003 | B1 |
6520647 | Raskar | Feb 2003 | B2 |
6791616 | Tamaki et al. | Sep 2004 | B2 |
Number | Date | Country | |
---|---|---|---|
20030002751 A1 | Jan 2003 | US |