image_segment_kmeans | R Documentation |
Segments image objects using clustering by the k-means clustering algorithm
image_segment_kmeans(
img,
bands = 1:3,
nclasses = 2,
invert = FALSE,
filter = FALSE,
fill_hull = FALSE,
plot = TRUE
)
img |
An |
bands |
A numeric integer/vector indicating the RGB band used in the
segmentation. Defaults to |
nclasses |
The number of desired classes after image segmentation. |
invert |
Invert the segmentation? Defaults to |
filter |
Applies a median filtering in the binary matrix? Defaults to
|
fill_hull |
Fill holes in the objects? Defaults to |
plot |
Plot the segmented image? |
A list with the following values:
image
The segmented image considering only two classes (foreground and
background)
clusters
The class of each pixel. For example, if ncluster = 3
,
clusters
will be a two-way matrix with values ranging from 1 to 3.
masks
A list with the binary matrices showing the segmentation.
Hartigan, J. A. and Wong, M. A. (1979). Algorithm AS 136: A K-means clustering algorithm. Applied Statistics, 28, 100–108. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2346830")}
img <- image_pliman("la_leaves.jpg", plot = TRUE)
seg <- image_segment_kmeans(img)
seg <- image_segment_kmeans(img, fill_hull = TRUE, invert = TRUE, filter = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.