Created
January 31, 2010 08:06
-
-
Save bebraw/290961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# not tested! the code should just give the general idea | |
import colorsys | |
# just some utility funcs to wrap colorsys and to offer support for list of colors | |
def rgb_to_yiq(colors): | |
return [colorsys.rgb_to_yiq(color) for color in colors] | |
def yiq_to_rgb(colors): | |
return [colorsys.yiq_to_rgb(color) for color in colors] | |
# get these from some source (histogram/whatever) | |
rgb_colors = [[0.9, 0.2, 0.7], [0.2, 0.5, 0.6], ] | |
yiq_colors = rgb_to_yiq(rgb_colors) | |
sorted_yiq = sorted(yiq_colors) # implement comparison func to sort based on I or Q. it uses cmp | |
# by default it sorts by Y | |
result_colors = yiq_to_rgb(sorted_yiq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment