deskew: Align and Orient an Image

View source: R/deskew.R

deskewR Documentation

Align and Orient an Image

Description

deskew rotates an image. By default, it attempts to identify any skew and then rotates it so that the lines are horizontal and the edges are vertical.

Usage

deskew(pix, binaryThreshold = 150, background = 255, angle = NA)
pixFindSkew(pix)

Arguments

n

pix

a Pix objectx

binaryThreshold

a value between 0 and 255 that is used as the cut-off for creating the binary image.

background

a value specifying the color for any pixels that are exposed when the image is rotated. 255 is white; 0 is black.

angle

an angle (in degrees rather than radians). If this is not specified, the skew is found using pixFindSkew having converted a copy of the Pix to a binary image to find any orientation

Value

A new Pix object that has been rotated.

Author(s)

Duncan Temple Lang

References

http://tpgit.github.io/UnOfficialLeptDocs/

See Also

pixRead pixConvertTo8

Examples

f = system.file("images", "DifferentFonts.png", package = "Rtesseract")
p = pixRead(f)
p2 = deskew(p, angle = 2)
plot(p2)

# Now deskew it.
p3 = deskew(p2)
plot(p3)


 # This is an example of where it matters.
f = system.file("images", "SMITHBURN_1952_p3.png", package = "Rtesseract")
p1 = pixRead(f)
p2 = pixConvertTo8(p1)
p2 = deskew(p2)
p6 = findLines(p2, 51, 5, FALSE)
p = pixAddGray(p2, p6)
plot(p)

duncantl/Rtesseract documentation built on March 25, 2022, 5:50 a.m.