Color Analysis

This document visualizes K-means clustering on the colors of a particular image design to determine the most important colors needed.

Setup The Function

##Execute Run the defined Function to get tables and Images

iv <- 1:12
pt <- proc.time()
w <- as.numeric()
for (i in iv) {
  g <- get_plots("Mur4.jpeg",i)
  grid.arrange(g[[1]], nrow=1)
  ggsave(paste("Mur_Segm_",i,".png",sep=""), g[[1]])
  cat("\n") 
  cat("## Num Colors: ", i, "\n")
  print(
   tagList(
    datatable(g[[2]]) %>%
      formatStyle("hex",
        backgroundColor = styleEqual(g[[2]]$hex, g[[2]]$hex)
      )
   )
  )
  
  cat("\n")
  
  
  w[i] <- g[[3]]
}
## Saving 7 x 5 in image
## Num Colors: 1
## Saving 7 x 5 in image
## Num Colors: 2
## Saving 7 x 5 in image
## Num Colors: 3
## Saving 7 x 5 in image
## Num Colors: 4
## Saving 7 x 5 in image
## Num Colors: 5
## Saving 7 x 5 in image
## Num Colors: 6
## Saving 7 x 5 in image
## Num Colors: 7
## Saving 7 x 5 in image
## Num Colors: 8
## Saving 7 x 5 in image
## Num Colors: 9
## Saving 7 x 5 in image
## Num Colors: 10
## Saving 7 x 5 in image
## Num Colors: 11
## Saving 7 x 5 in image
## Num Colors: 12

How Well Do The Clusters Fit?

wdf <- data.frame(k=iv, wss = w)

gg <- ggplot(wdf, aes(x=k, y=wss)) +
  geom_line() +
  geom_point()
gg