Skip to contents

arcLength estimates a closed contour perimeter or a curve length from a set of 2D coordinates.

Usage

arcLength(curve, closed = TRUE)

Arguments

curve

An m x 2 matrix of 2D coordinates.

closed

A boolean indicating whether the curve is closed (perimeter) or not (default: TRUE).

Value

A numerical value.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

dots <- image(system.file("sample_img/dots.jpg", package = "Rvision"))
dots_gray <- changeColorSpace(dots, "GRAY")
dots_bin <- dots_gray < 200
contours <- findContours(dots_bin)
ix <- contours$contours[, 1] == 0
arcLength(contours$contours[ix, 2:3])
#> [1] 352.6346