User interface method for skew correction
View Patent ↗Methods and systems for correcting skew in digital images are disclosed according to embodiments of the invention. Embodiments may include receiving the endpoints of the skew-line, calculating the sine and cosine of the skew-angle from the endpoints and rotating the image using the sine and cosine of the skew-angle. Embodiments of the invention may also include various ways for a user to provide a skew-line and/or endpoints.
1. A method for correcting skew in an image, the method comprising:
receiving, by an input device, at least two distinct points on a skew-line from a user, wherein the at least two distinct points on the skew-line are immediately updated with every move of the input device by the amount specified by a current position of the input device;
calculating the sine and cosine of the skew-angle, wherein the skew-angle is the angle defined by the intersection of the skew-line with respect to a reference line, and the skew-angle is calculated using the points having coordinates (x 1 , y 1 ) and (x 2 , y 2 ), the calculating of the sine and cosine using the formulas:
sin
(
θ
)
=
(
y
2
-
y
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
,
cos
(
θ
)
=
(
x
2
-
x
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
;
and
transforming the image according to the sine and cosine of the skew-angle, wherein the transforming is updated with the movement of the input device.
2. The method according to claim 1 , wherein the two of the at least two points are endpoints.
3. The method according to claim 1 , wherein the reference line comprises a horizontal line.
4. The method according to claim 1 , further comprising cropping the image.
5. The method according to claim 1 , wherein the two points of the skew-line are received from a user through a user interface.
6. The method according to claim 1 , further comprising displaying the image after the image has been transformed.
7. A method for correcting skew in an image, the method comprising:
receiving, by an input device, a first endpoint from a user;
receiving a second endpoint from the user, wherein the first and second endpoints are immediately updated with every move of the input device by the amount specified by a current position of the input device;
calculating the sine and cosine of the skew-angle, wherein the skew-angle is the angle between a line defined by the first and second endpoints and a reference line, and the sine and cosine are calculated using the first and second endpoints having coordinates (x 1 , y 1 ) and (x 2 , y 2 ) using the formulas:
sin
(
θ
)
=
(
y
2
-
y
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
,
cos
(
θ
)
=
(
x
2
-
x
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
;
and
transforming the image using the sine and cosine of the skew-angle, wherein the transforming is updated with the movement of the input device.
8. The method according to claim 7 , further comprising drawing a line between the first endpoint and the second endpoint on the display.
9. A computer system comprising:
a user interface comprising a pointing device and a display;
a processor; and
a memory, wherein the memory comprises:
instructions to store an image in the memory;
instructions to display the image on the display;
instructions to receive a first endpoint and a second endpoint from a user through the pointing device, wherein the first and second endpoints are immediately updated with every move of the input device by the amount specified by a current position of the pointing device;
instructions to calculate with the processor the sine and cosine of a skew-angle, wherein the skew-angle is the angle between a reference line and a line defined by the first endpoint and the second endpoint, and the sine and cosine are calculated using the first and second endpoints having coordinates (x 1 , y 1 ) and (x 2 , y 2 ) using the formulas:
sin
(
θ
)
=
(
y
2
-
y
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
,
cos
(
θ
)
=
(
x
2
-
x
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
;
and
instructions to transform the image using the sine and cosine of the skew-angle, wherein the transforming is updated with the movement of the input device.
10. The computer system according to claim 9 , further comprising instructions to display a symbol representing the first endpoint and a symbol representing the second endpoint on the display.
11. The computer system according to claim 9 , further comprising instructions to draw a line defined by the first endpoint and the second endpoint on the display.
12. The computer system according to claim 11 , further comprising instructions to erase from the display the line defined by the first endpoint and the second endpoint.
13. The computer system according to claim 9 , further comprising instructions to crop the image.
14. The computer system according to claim 9 , further comprising instructions to enlarge the image.
15. A non-transitory computer program product comprising:
a computer readable medium encoded with program code for controlling operation of a computer system, the program code including:
program code to display an image;
program code to receive a first endpoint and a second endpoint from a user through a pointing device, wherein the first and second endpoints are immediately updated with every move of the input device by the amount specified by a current position of the pointing device;
program code to calculate the sine and cosine of the skew-angle, wherein the skew-angle is the angle between a reference line and a line defined by the first endpoint and the second endpoint, and the sine and cosine are calculated using the first and second endpoints having coordinates (x 1 , y 1 ) and (x 2 , y 2 ) using the formulas:
sin
(
θ
)
=
(
y
2
-
y
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
,
cos
(
θ
)
=
(
x
2
-
x
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
;
and
program code to transform the image using the sine and cosine of the skew-angle, wherein the transforming is updated with the movement of the input device.
16. The non-transitory computer program product according to claim 15 , further comprising program code to draw a line defined by the first endpoint and the second endpoint.
17. The non-transitory computer program product according to claim 16 , further comprising erasing the line defined by the first endpoint and the second endpoint.
18. The non-transitory computer program product according to claim 15 , wherein the first endpoint and the second endpoint is received from a user through a user interface.
19. A computer system comprising:
a user interface comprising:
a pointing device;
a scanner;
and a display;
a processor; and
memory, wherein the memory comprises:
instructions to receive an image of a document from a scanner;
instructions to store the image in the memory;
instructions to check the image for skew;
instructions to display the image on the display;
instructions to receive a first endpoint and a second endpoint from a user through the pointing device, wherein the first and second endpoints are immediately updated with every move of the input device by the amount specified by a current position of the pointing device;
instructions to calculate with the processor the cosine and sine of the skew-angle, wherein the skew-angle is the angle between a horizontal line and a line defined by the first endpoint and the second endpoint, and the sine and cosine are calculated using the first and second endpoints having coordinates (x 1 , y 1 ) and (x 2 , y 2 ) using the formulas:
sin
(
θ
)
=
(
y
2
-
y
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
,
cos
(
θ
)
=
(
x
2
-
x
1
)
(
y
2
-
y
1
)
2
+
(
x
2
-
x
1
)
2
;
and
instructions to transform the image using the sine and cosine of the skew-angle, wherein the transforming is updated with the movement of the input device.
20. The method of claim 1 , further comprising:
assigning a value to the sine and cosine of the skew-angle in response to the calculating;
performing a check to determine if the value assigned to the cosine is a negative value;
negating the value assigned to the sine and cosine of the skew-angle in response to a determination that the value assigned to the cosine is negative.
21. The method of claim 1 , wherein the transforming comprises:
configuring a deskewed image space by creating a composite coordinate (x′, y′) for each (x, y) coordinate in the skewed image with the equations:
x ′( x,y )= x cos(θ)+ y sin(θ), and
y ′( x,y )= y cos(θ)− x sin(θ).