Images as Voronoi tesselations

November 28, 2012

(This article was first published on is.R(), and kindly contributed to R-bloggers)

This is probably the coolest-looking thing I’ve figured out how to do with raster images in R. Similar to (although not quite as impressive as) these images by Jeff Clark, I alter the simple k-means approach described in the previous post to cluster primarily in Cartesian space, rather than in color space. This produces, essentially, Voronoi regions shaded with a region-average color, and the effect is really neat.

Note that increasing nRegions can produce drastically different results, but that kmeans() is quite slow as nRegions increases. Below, you’ll find a few examples, as well as the code. If you use this to make anything impressive, share it with us at @isDotR.

To leave a comment for the author, please follow the link and comment on their blog: is.R(). offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)