plotSubsets: Plot a collection of individual a Bounding Boxes

View source: R/plot.R

plotSubsetsR Documentation

Plot a collection of individual a Bounding Boxes

Description

This is a convenience wrapper to apply the plotSubImage function over a collection of bounding boxes. It takes a collection of bounding boxes from GetBoxes and an image and displays the subset of the image specified by the bounding box arranged in a panel grid, with the recognized output and associated confidences printed in the title. 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

plotSubsets(bbox, img, nrow = 4, ncol = 4,
            titles = paste("OCR: ", row.names(bbox),
                            ", conf: ", round(bbox[,"confidence"],0)),
             ...)

Arguments

bbox

bounding boxes as created by GetBoxes, with columns left, bottom, right, top, and confidences and rownames of the recognized characters.

img

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

nrow

the number of rows in the panel.

ncol

the number of columns in the panel.

titles

character vector of plot titles for the different panels/plots.

...

additional arguments passed to the inherited plotSubImage methods.

Value

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

Author(s)

Matthew Espe

See Also

GetBoxes plotSubImage

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)
  plotSubsets(bbox, img, nrow = 10, ncol = 1)
}

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