Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fastKmeans

fast kmeans clustering for 2D or 3D point clouds


Description

fast kmeans clustering for 2D or 3D point clouds - with the primary purpose to get a spatially equally distributed samples

Usage

fastKmeans(x, k, iter.max = 10, project = TRUE, threads = 0)

Arguments

x

matrix containing coordinates or mesh3d

k

number of clusters

iter.max

maximum number of iterations

project

logical: if x is a triangular mesh, the centers will be projected onto the surface.

threads

integer number of threads to use

Value

returns a list containing

selected

coordinates closest to the final centers

centers

cluster center

class

vector with cluster association for each coordinate

Examples

require(Rvcg)
data(humface)
set.seed(42)
clust <- fastKmeans(humface,k=1000,threads=1)
## Not run: 
require(rgl)

## plot the cluster centers
spheres3d(clust$centers)

## now look at the vertices closest to the centers
wire3d(humface)
spheres3d(vert2points(humface)[clust$selected,],col=2)

## End(Not run)

Morpho

Calculations and Visualisations Related to Geometric Morphometrics

v2.8
GPL-2
Authors
Stefan Schlager [aut, cre, cph], Gregory Jefferis [ctb], Dryden Ian [cph]
Initial release
2020-02-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.