| image_crop_baselineareas | R Documentation |
Extract areas between baselines
image_crop_baselineareas( image, x, textregion, extend = TRUE, horiz = FALSE, enlarge = 0, color = "royalblue", border = "10x10", overview = TRUE, max_width = +Inf, trace = FALSE, ... )
image |
|
x |
a list vector where each list element contains columns x and y indicating the positions of the baseline |
textregion |
a list vector of the same length of |
extend |
logical indicating to extend the baseline to the left and right of the image. Defaults to TRUE. |
horiz |
logical indicating to extend the baselines horizontally. Defaults to FALSE. |
enlarge |
argument passed on to |
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 |
... |
further arguments currently not used |
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(opencv)
library(magick)
path <- system.file(package = "madoc.utils", "extdata", "pagexml-example.xml")
x <- read_pagexml(path)
x
img <- system.file(package = "madoc.utils", "extdata", "pagexml-example.jpg")
img <- ocv_read(img)
areas <- image_crop_baselineareas(img, x = x$baseline, extend = FALSE, trace = TRUE)
areas$areas
image_resize(areas$overview, "x600")
areas <- image_crop_baselineareas(img, x = x$baseline, extend = TRUE, color = "red")
image_resize(areas$overview, "x600")
## Multiple regions
path <- system.file(package = "madoc.utils", "extdata", "multiregion-page.xml")
x <- read_pagexml(path)
x
img <- system.file(package = "madoc.utils", "extdata", "multiregion.jpg")
img <- ocv_read(img)
areas <- image_crop_baselineareas(img,
x = x$baseline, textregion = x$points,
extend = TRUE, overview = FALSE)
overview <- image_rbind(areas, color = "grey", geometry = "5x5")
image_resize(overview, "600")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.