Skip to content

Commit

Permalink
Added title to plot_palette.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfe committed Dec 30, 2011
1 parent 7a99ed6 commit 1a961e3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions r/palette.rscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# - Package 'cclust'
#
# Quick run:
# library(ReadImages)
# library(cclust)
# source("~/path/to/palette.rscript")
# source("~/path/to/this/palette.rscript")
#
# plot_palette("/path/to/image") # Find 10 clusters (default)
# plot_palette("/path/to/image", 20) # Find 20 clusters
Expand All @@ -20,6 +18,9 @@
# p = palette(image, 10, 20)
# plot(p)

library(ReadImages)
library(cclust)

palette <- function(im, palette_size, iterations) {
# Convert the image into a list of observations, each observation
# is a 3-dimensional vector of RGB. For cclust we represent this
Expand Down Expand Up @@ -58,4 +59,6 @@ plot_palette <- function(image, palette_size=10, iterations=20) {
layout(matrix(c(1, 2, 1, 2), 2, byrow=T))
plot(im)
plot(fm)

title(sprintf("Clusters: %d", palette_size))
}

0 comments on commit 1a961e3

Please sign in to comment.