image_crop_textlines | R Documentation |
Crop out areas with text lines from an image
image_crop_textlines( image, geometries, color = "royalblue", border = "10x10", overview = TRUE, max_width = +Inf, trace = FALSE )
image |
|
geometries |
a data.frame with columns width, height, x_left, y_top indicating the areas to extract from the image |
color |
color to use for adding a border in the overview image. Defaults to 'royalblue'. |
border |
border pixels to using in the overview image. Defaults to 10x10 pixel borders. |
overview |
logical indicating to add the overview image of all area's below each other. Defaults to TRUE. |
max_width |
maximum width of the overview image. Defaults to +Inf |
trace |
logical indicating to trace progress |
a list with elements areas and overview where overview
is a magick-image
with stacked image lines
and areas
is a list of magick-image
's, one for each text line.
In case overview is set to FALSE
the return value is only the list of stacked image lines.
library(magick) library(data.table) path <- system.file(package = "madoc.utils", "extdata", "alto-example.xml") x <- read_alto(path) x$width <- as.integer(x$WIDTH) x$height <- as.integer(x$HEIGHT) x$x_left <- as.integer(x$HPOS) x$y_top <- as.integer(x$VPOS) x <- subset(x, grepl(ID, pattern = "line")) rownames(x) <- x$ID img <- system.file(package = "madoc.utils", "extdata", "alto-example.jpg") img <- image_read(img) areas <- image_crop_textlines(img, x, color = "red") areas$overview areas$areas
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.