Raw implementation of kmean and mean shift algorithm