Skip to contents

Extracts the external contour of each object in a labeled matrix (e.g., from watershed segmentation). It returns a list of coordinates for each object.

Usage

contour(labels)

Arguments

labels

A labeled image object or a matrix containing integer labels. Typically the result of image_watershed() or similar segmentation.

Value

A list where each element is a matrix of (x, y) coordinates for the contour of the respective object, named by the object label ("1", "2", ...).

Examples

library(pliman)
# generate a binary image
img <- image_pliman("soybean_touch.jpg")
bin <- image_binary(img, "B")[[1]]

# watershed segmentation
wat <- image_watershed(bin)
# extract contours
cont <- contour(wat)
plot(img)
plot_contour(cont, col = "red", lwd = 2)