image_crop_textpolygons: Crop out areas with text polygons from an image

View source: R/img.R

image_crop_textpolygonsR Documentation

Crop out areas with text polygons from an image

Description

Crop out areas with text polygons from an image

Usage

image_crop_textpolygons(
  image,
  geometries,
  color = "royalblue",
  border = "10x10",
  overview = TRUE,
  max_width = +Inf,
  trace = FALSE
)

Arguments

image

image either an object of class opencv-image or a path to an image file on disk

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

Value

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.

Examples

library(opencv) 
library(data.table)
path     <- system.file(package = "madoc.utils", "extdata", "pagexml-example.xml")
x        <- read_pagexml(path)

img      <- system.file(package = "madoc.utils", "extdata", "pagexml-example.jpg")
img      <- ocv_read(img)
area     <- ocv_polygon(img, pts = x$coords[[5]])
areas    <- image_crop_textpolygons(img, x, color = "red")
areas$overview
areas$areas

DIGI-VUB/madoc.utils documentation built on Sept. 14, 2022, 3:03 p.m.