image_crop_area: Extract a polygonal region

View source: R/img.R

image_crop_areaR Documentation

Extract a polygonal region

Description

Extract a polygonal region, optionally limiting the extracting to the bounding box

Usage

image_crop_area(image, x, bbox = FALSE, ...)

Arguments

image

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

x

a list vector where each list element contains columns x and y indicating the positions of the points of the polygon or a single data.frame with columns x and y

bbox

logical indicating to limit the result to the bounding box of the polygon

...

further arguments currently not used

Value

a magick-image or a list of magick-image objects

Examples

library(opencv)
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)
pts      <- x$points[[1]]
area     <- image_crop_area(img, pts, bbox = FALSE)
area
area     <- image_crop_area(img, pts, bbox = TRUE)
area
areas    <- image_crop_area(img, x$points, bbox = FALSE)

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