Algorithm challenge: Generate color scheme from an image

  1. To find the primary X colors, screencap the app. Run a color histogram on the image. The top X colors in the histogram are the theme. Edit: if gradients are used, you’ll want to pick distinct “peaks” of colors; that is, you may have a whole bunch of colors right around “orange” if orange is one of the main colors used in the gradients. Effectively, just enforce a certain amount of distance between your colors chosen from the histogram.

  2. Tweaking the color scheme can best be done in HSV space; convert your colors to HSV space, and if the users want it to be “Brighter”, increase the Value, if they want it to be more “Colorful”, increase the Saturation, etc.

  3. Determining the text color can best be done by characterizing areas of high variability (high frequency in Fourier space). Within those areas, you should have either: two colors, text and background, in which case your text is the lesser-used color; or you’ll have several colors, text and background image colors, in which case the text color is the most common color.

Leave a Comment