pixelsInContour: Which Pixels are Inside a Contour

View source: R/shape.R

pixelsInContourR Documentation

Which Pixels are Inside a Contour

Description

pixelsInContour determines the pixels that are inside a specified contour.

Usage

pixelsInContour(contours, id = NULL)

Arguments

contours

A list of two matrices as produced by findContours.

id

An optional vector indicating the identity of the specific contours for which to run the function.

Value

A matrix with 3 columns:

  • "id": the contour identity (indicates the set of points belonging to the same contour).

  • "x": the x coordinates of the points inside the contour.

  • "y": the y coordinates of the points inside the contour.

Author(s)

Simon Garnier, garnier@njit.edu

See Also

findContours

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)
pixelsInContour(contours, id = c(3, 5))


swarm-lab/Rvision documentation built on Feb. 7, 2024, 4:59 a.m.