Colorpalette from image: nice to have

Open
#84 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia

Research direction

Start with _assets/scripts/getColorPalette.jl and review the referenced Julia approach using Clustering, Colors, Random, and Images. Determine the appropriate built-in ColorSchemes API and dependency scope from that example. Done means ColorSchemes provides a supported way to obtain color palettes from images, with behavior matching the intended use case.

Written by the indexing model from the issue text.

Description

I do have this script to obtain colorpalettes from images (like the ones for Taylor Swift :D, https://twitter.com/drob/status/1459259255312236547 ). However, probably it will be nice to have a built-in function in ColorSchemes for this. Just in case this is of interest, here the relevant code (probably not the best approach, but it works).

using Clustering, Colors, Random
using Images: load, RGB, channelview, permutedims

function getColorPalette(image; ncolors = 5)
        img_CHWa = channelview(image)
        #img_CHW = permutedims(img_CHWa, (1,3,2))
        testmat = reshape(img_CHWa, (3, size(image)[1]*size(image)[2])) #input shape
        sol = kmeans(testmat, ncolors)
        csize = counts(sol) # get the cluster sizes
        colores = sol.centers # get the cluster centers, dominat colors
        indxc = sortperm(csize)
        colores, indxc
end
Dominant language
Julia
Stars
268
Forks
44
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaGraphics/ColorSchemes.jl

All issues in JuliaGraphics/ColorSchemes.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.