plot.BoundingBox: Plot function for a Bounding Box

plotSubImageR Documentation

Plot function for a Bounding Box

Description

The plotSubImage function takes a bounding box and an image and displays the subset of the image specified by the bounding box. The bounding box is a vector of length 4 giving the pixel indices x1, y1, x2, y2 of the corners of the rectangular bounding box. We use this to draw a separate plot for a term recognized by the OCR mechanism. This is useful for looking at misclassified terms.

This is unrelated to the tesseract API and is used for examining the region of the image in R.

Usage

plotSubImage(box, img, text = character(), ...)

Arguments

box

a vector of length 4 giving the x1, y1, and x2, y2 coordinates of the sub-region.

img

the image object read using the appropriate function in the appropriate package for the image type. See png, rjpeg, or tiff.

text

a character vector providing the recovered text for each row in box, or the empty character vector.

...

additional arguments passed to the inherited plot methods.

Value

The purpose of this function is the side-effect of plotting the sub-image The result is NULL.

Author(s)

Duncan Temple Lang

See Also

GetBoxes

Examples

f = system.file("images", "OCRSample2.png", package = "Rtesseract")
pix = pixRead(f)
api = tesseract(pix)
bbox = GetBoxes(api, "textline")
#Recognize(api)
#bbox = lapply(api, BoundingBox, "textline")

if(FALSE && require("png")) {
  img = png::readPNG(f)
  par(mfrow = c(3, 3))
  invisible(lapply(bbox, plotSubImage, img))
  invisible(lapply(bbox, plotSubImage, img, axes = FALSE, xlab = "", ylab = ""))
}

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