Nice idea. I confess I'm slightly not too keen on the word "Novelty" - 
reminds me of cheap Christmas presents... :)  You could consider making the 
package a bit more general...  For my purposes I've been using a small bit 
of code that extracts a selection of colors from images to make a palette. 
Basically, it's this:

    using Images, Colors, Clustering

    function dominant_colors(img, n=10, i=10, tolerance=0.01; resize = 1)
        w, h = size(img)
        neww = round(Int, w/resize)
        newh = round(Int, w/resize)
        smaller_image = Images.imresize(img, (neww, newh))
        imdata = convert(Array{Float64}, 
raw(separate(smaller_image).data))/256
        w, h, nchannels = size(imdata)
        d = transpose(reshape(imdata, w*h, nchannels))
        R = kmeans(d, n, maxiter=i, tol=tolerance)
        cols = RGB{Float64}[]
        for i in 1:nchannels:length(R.centers)
            push!(cols, RGB(R.centers[i], R.centers[i+1], R.centers[i+2]))
        end
        return cols, R.cweights/sum(R.cweights)
    end

    sorted_palette, wts = 
dominant_colors(imread("/tmp/van-gogh-starry-sky.png"), 10, 40, resize=3)

which gives a selection of colors from the image (with weights if needed). 
An interesting feature of this is that the results always vary slightly 
each time - sometimes I stack them to see the differences:

<https://lh3.googleusercontent.com/-jdRcudzT78o/VlVpwJWQWvI/AAAAAAAAALE/jGOqal2nDA4/s1600/van-gogh-result-1.png>




Reply via email to