Skip to contents

fillConvexPoly fills all the pixels of an image withing a given convex polygon with a given color. This function is much faster than the function fillPoly. It can fill not only convex polygons but any monotonic polygon without self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line) twice at the most (though, its top-most and/or the bottom edge could be horizontal).

Usage

fillConvexPoly(image, polygon, color = "white")

Arguments

image

An Image object.

polygon

An m x 2 matrix (or an object that can be converted to an m x 2 matrix), with the first column containing the x coordinates of the polygon and the second column containing the y coordinates of the polygon.

color

A value or vector of any kind of R color specification compatible with col2bgr representing the color to fill the polygon with (default: "white").

Value

This function does not return anything. It modifies image in place.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
poly <- data.frame(x = c(290, 290, 440, 440), y = c(170, 325, 325, 170))
fillConvexPoly(balloon, poly, color = "red")
#> NULL