Code for EMIS/CSE 8331 by Michael Hahsler

Cluster an image

library("png")
library("seriation")

p <- readPNG("horses.png")
dim(p)
## [1] 536 750   3

Show the different channels

pimage(p[,,1], prop = TRUE,
  col = rgb(seq(0,1, length.out = 10), 0,0))

pimage(p[,,2], prop = TRUE,
  col = rgb(0,seq(0,1, length.out = 10),0))