Learn R Programming

imager (version 0.42.10)

contours: Return contours of image/pixset

Description

This is just a light interface over contourLines. See help for contourLines for details. If the image has more than one colour channel, return a list with the contour lines in each channel. Does not work on 3D images.

Usage

contours(x, nlevels, ...)

Arguments

x

an image or pixset

nlevels

number of contour levels. For pixsets this can only equal two.

...

extra parameters passed to contourLines

Value

a list of contours

See Also

highlight

Examples

Run this code
# NOT RUN {
boats.gs <- grayscale(boats)
ct <- contours(boats.gs,nlevels=3)
plot(boats.gs)
#Add contour lines
purrr::walk(ct,function(v) lines(v$x,v$y,col="red"))
#Contours of a pixel set
px <- boats.gs > .8
plot(boats.gs)
ct <- contours(px)
#Highlight pixset
purrr::walk(ct,function(v) lines(v$x,v$y,col="red"))
# }

Run the code above in your browser using DataLab