Kohonen RGB example

Ron Wehrens and Johannes Kruisselbrink

RGB Mapping with Gaussian neighbourhood

library(kohonen)
library(grid)
cells <- 20
colors <- rbind(c(1,0,0), c(1,1,0), c(0,1,0), c(0,1,1), c(0,0,1), c(1,0,1))
init <- replicate(3, runif(cells * cells))
somgrid <- somgrid(cells, cells, "rectangular", neighbourhood.fct = "gaussian")
som.rgb <- supersom(
  data = colors,
  grid = somgrid,
  init = init,
  rlen = 1000,
  mode = "online",
  keep.data = FALSE)

RGB Mapping with Bubble neighbourhood

cells <- 20
colors <- rbind(c(1,0,0), c(1,1,0), c(0,1,0), c(0,1,1), c(0,0,1), c(1,0,1))
init <- replicate(3, runif(cells * cells))
somgrid <- somgrid(cells, cells, "rectangular", neighbourhood.fct = "bubble")
som.rgb <- supersom(
  data = colors,
  grid = somgrid,
  init = init,
  rlen = 1000,
  mode="online",
  keep.data = FALSE)