如何从图像中生成突出颜色的调色板? [英] How can I generate a palette of prominent colors from an image?

查看:423
本文介绍了如何从图像中生成突出颜色的调色板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何对图片中的所有像素进行取样,并从中生成一个颜色调色板,例如。我不知道从哪里开始。任何人都可以指向正确的方向?

I'm trying to figure out how to sample all of the pixels in an image and generate a palette of colors from it, something like this or this. I have no idea where to even begin. Can anyone point me in the right direction?

__ EDIT:__
<

__ __

到目前为止:

我使用这个 Pixelate 函数来获取像joe_coolish这样的大块区域建议。它工作完美,给我一个很好的样本的颜色(这是从窗口样本果冻鱼图片):

I used this Pixelate function to get large block sections like joe_coolish suggested. It's working perfectly and giving me a pretty good sample of colors to work with (this is from the windows sample jelly fish picture):

现在,如果有人可以帮助我获得5种最明显的颜色(最深的蓝色,最浅的蓝色,灰色和桃子(?)),我会永远爱你。我真的不明白如何平均或添加颜色在一起。我也不知道如何判断一个颜色是否类似于程序化,在你的解释中有一些许多数字和变量,我迷路了,想知道什么正在做什么对谁。

Now, if someone could help me get the 5 most distinct colors (darkest blue, lightest blue, orange, gray and peach(?)), I would love you forever. I really don't understand how to average or add colors together. I also can't figure out how to tell if a color is similar programatically, there are some many numbers and variables in you explanations that I get lost trying to figure out what's doing what to whom.

推荐答案

涉及代码的答案告诉你如何获得完整的调色板。

The answers involving the code show you how to get the full palette. If you want to get the average colors like in the websites you posted, this is how I would do it.

源映像:

我会通过应用低通滤波器(类似高斯模糊)来平均颜色。

First, I would average the colors by applying a lowpass filter (something like a Gaussian Blur)

这样限制了整个调色板。从那里我将屏幕分成N块(N是你想要的调色板的总像素数)

That way you are limiting the total palette. From there I would divide the screen into N blocks (N being the total number of pixels you want in your palette)

从那里,目标每个块,并迭代每个像素,像素,并将其添加到您的调色板索引。结果如下:

From there, target each block and iterate over each pixel, and get the average pixel for that block and add it to your palette index. The result is something like this:

这样你的调色板是有限的,你得到不同地区的平均颜色。你可以在代码中做所有的,如果你想要一些帮助,让我知道,我会发布一些。这只是高级我会做什么。

That way your palette is limited and you get the average colors from the different regions. You can do all of that in code, and if you'd like some help with that, let me know and I'll post some. This is just the High Level "what I would do".

这篇关于如何从图像中生成突出颜色的调色板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆