Skip to content

atisor73/chromatose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chromatose


A package for storing and visualizing palettes, and constructing new ones via polynomial interpolation and image extraction. Now pippable!

*This package borrows inspiration from @jmaasch's scatterplots in her package [`sanzo`](https://github.com/jmaasch/sanzo), and uses extraction algorithms from @qTipTip's package [`Pylette`](https://github.com/qTipTip/Pylette).*

palettes 🎨

frieda plath selah blonde honeycombe
crepuscule leather gucci sandbar fiestaware
chilaquiles eleven splenda gremlin pollen
medium juniper polya ostrich fraiche
cheshire carmine joan* pinot addams
minuit fugazi clementine leda pugsley
bellhooks wes lysergic pepo reese
lufte oolong pitaya alice neko
belle spiff yoshi phoebe pam
menthol dwight riley mona eeyore
rory pudding marmalade polaris trefoil
harmon abed shirley surely annie
pierce britta strogatz lutz writhe
perl* roosh seafare heliotrope moonbow
peanuts naval indomie maggie rainbow
??? quinone quinoline diverging orb*
warble* waitomo* vylette* pom* lava*
pumpkin* pinctada* nacre* moxxi* salvia*
bluefish BuPu* holst joker* rach*
blink* betan* rue* otterpop* gummi*
emporium paired category20a category20b category20c

* available as xxx256

[discrete] [monochrome continuous] [polychromatic continuous] [bokeh]

viz 👀

ct.palplot( )

Visualizations include swatches, pies, points, lines, scatters. Somewhat helpful for seeing how colors behave on a plot, in dense or scattered visuals. Sometimes colors look great together on a swatch, but not so great in their pointillistic forms.

  • palette : list or iterable any combination of hex strings or rgb tuples or HTML
  • bg_color : HTML or hex string background fill color
  • alpha : fraction between 0.0 and 1.0 alpha transparency of entire palette
  • shuffle : boolean shuffles palette

ct.palpicker( )

Testing out panel's new colorpicker widget! Useful for adjusting palettes to personal taste.

  • n : list or integer

interpolation ✂️

ct.palpolate( )

palpolate (pal-(ette inter)-polate): input lists of any size and user can control output size.

There are a multitude of beautiful gradients in packages like bokeh and colorcet that are, for the most part, static. The interpolation scheme here can be used to create entirely new ones given only a few endpoints. This part is still in development, but currently uses linear or polynomial fits in color space metrics RGB, HSL, or HSV. Heatmaps are a good way to visualize the results!

On the left are the input palettes, and on the right are the output palettes all approximately of size 256.

  • palette : list or iterable any combination of hex strings or rgb tuples or HTML
  • n_colors : integer approximate desired length of final palette
  • method : string 'rgb' or 'hsv' or 'hsl' interpolation metric, default 'rgb'
  • curve : boolean if True, fit t 2ndº polynomial if False, simple linear interpolation
  • directions : list of 3 strings, 'up' or 'down' each entry corresponds to r, g, b 'up' pushes intermediate values higher (lighter) 'down' pushes intermediate values lower (darker)

extraction 📷

Extract palette of size n_colors from image given image path using k-means or median cut algorithms.

ct.extract( )

  • path : string of image path
  • n_colors : integer number of colors to extract
  • method : 'kmeans' or 'median' or 'both' algorithm of extraction either k-means clustering or median cut, default k-means
  • resize : boolean, default True resizing samples a smaller image, speeds up extraction
  • sort : boolean, default False amateur sort by luminance
  • show : boolean, default True prints palette and returns panel object

command-line tools 👇

Palettes can be retrieved from command line:

>>> chromatose leda
>>> ['#2c2f30', '#8fa7d7', '#afd7d6', '#aa3731', '#f5b3b8']

Palettes can be extracted from command line:

>>> extract egg.png
>>> K-Means:    ['#050002', '#0c1c7b', '#013adc', '#1b143a', '#294254']
>>> Median Cut: ['#040000', '#080006', '#1e1b3c', '#1e2d61', '#0330bd']

Palette extraction from image path using both k-means and median cut
algorithms. Defaults to 5 colors, resized, unsorted, and not displayed.

 path             path to image

 -n , --ncolors   length of palette (int, default 5)
 -r , --resize    resize for efficiency (bool, default True)
 -s , --show      display pillow swatches (bool, default False)

gallery 🌈

frieda

plath

selah

blonde

honeycombe

lysergic

pepo

reese

rainbow

lufte

pitaya

spiff

leather

medium

addams

mona

leda

rory

pudding

polaris

trefoil

writhe

perl*

roosh

heliotrope

indomie

strogatz

juniper

quinone

minuit

alice

wes

pam

dwight

marmalade

harmon

shirley

annie

pierce

britta

abed

eeyore

neko

maggie

quinoline

peanuts

eleven

naval

fugazi

clementine

diverging

lutz

moonbow

chilaquiles

fiestaware

polya

splenda

pollen

fraiche

cheshire

bellhooks

belle

phoebe

ostrich

yoshi

salvia*

pom*

lava*

moxxi*

joan*

waitomo*

warble*

vylette*

pumpkin*

crest*

nacre*

salvia256

warble256

waitomo256

vylette256

pom256

moxxi256

lava256

pumpkin256

joan256

nacre256

crest256

joker*

rach*

orb*

blink*

rue*

betan*

bluefish

otterpop*

gummi*

emporium*

perl256

orb256

blink256

otterpop256

gummi256

emporium256

betan256

rue256

rach256

joker256

paired

category20a

category20b

category20c


"The last color she remembered was the indigo chips in the headstone. After that she became as color conscious as a hen."