GetImageInfo: Get Information about the Current Tesseract Image

GetImageInfoR Documentation

Get Information about the Current Tesseract Image

Description

These methods provide information about the current image being processed by a tesseract OCR instance. We can query the dimensions of the image (rows, columns and depth) and also information about the samples per pixel, x and y resolution (not pixels), the format and the color depth.

Usage

GetImageInfo(obj, ...)
GetImageDims(obj, ...)

Arguments

obj

an object of class TesseractBaseAPI-class objected created via a call to tesseract.

...

additional arguments for future methods

Value

GetImageInfo returns a numeric vector with 5 elements.

samplesPerPixel
xres
yres
informat
colorDepth

GetImageDims returns a numeric vector with 3 elements.

height

the number of rows

width

the number of columns

depth

the number of "planes" in the image

In either case, if there is no image, the method returns NULL.

Note

It is possible to pass a Pix-class object as the value of obj in these functions. One can obtain the Pix-class object via a call to the unexported SetImage or GetImage, or alternatively, via pixRead. If one obtains the Pix-class instance from a tesseract instance, it is only valid as long as the corresponding tesseract object is valid and not garbage collected. In other words, if you obtain the image and then remove the references to the tesseract object, you should not use the image object.

Author(s)

Duncan Temple Lang

References

Tesseract API Documentation.

See Also

tesseract SetImage

Examples

f = system.file("images", "DifferentFonts.png", package = "Rtesseract")
ts = tesseract(f)
GetImageDims(ts)
GetImageInfo(ts)

## Not run: 
# Don't get the Pix object this way.
pix = GetInputImage(ts, FALSE)
GetImageDims(pix)
GetImageInfo(pix)
rm(pix)

## End(Not run)

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