Algorithm challenge: Generate color scheme from an image

前端 未结 11 1741
猫巷女王i
猫巷女王i 2020-12-02 05:02

Background

So, I\'m working on a fresh iteration of a web app. And, we\'ve found that our users are obsessed with being lazy. Really lazy. In fact, the more wor

11条回答
  •  北海茫月
    2020-12-02 05:06

    Similar to McWafflestix's solution, the specifics will need to be tweaked, but my general approach would be...

    (I agree that HSV is the right space)

    1. Grab a histogram of the image, filter it to smooth the noise, and find the highest score where V and S are in a (possibly dynamic) gamut of likely "subject" colors. A red bird on a blue sky will require that we be smart enough not to base our scheme on the blue, but on the red. This may require some guesses about photo composition, like "centered in the frame" and "rule of thirds" analysis could give you a probability of a color being relevant. Regardless, this is our the base color.

    2. Along the lines of Kuler, calculate colors that compliment the base by moving around the color wheel. Extra points for a calculated compliment if it also appeared prominently in the histogram from step 1.

    3. Use the base color and calculated compliments to derive pleasing adjunct colors, such as lighter and darker versions of each, more or less saturated, etc.

提交回复
热议问题