分层颜色节点的算法
我有一个网络,其中节点是分层定义的(通过 UN SITC 编码)。在我的应用程序中,每个节点都有四个逐渐增加的层次特异性的识别数字(例如,请参阅产品 7431) 但我定义的网络不仅仅是明显的层次结构。我想做的是按层次对节点进行着色,但根据我的网络计算对它们进行布局,并查看两者重合的程度。
一般来说,我正在寻找一种方法来生成 N 个调色板,这些调色板在视觉上尽可能地彼此不同(显然,随着 N 的增长,它的效率越来越低),然后将它们划分为子调色板,直到达到所需的效果。层次深度。
具体来说,这意味着为第一个数字选择 10 个基色,并为每个数字生成 K<=10 种颜色的调色板,其中 K 是第二个数字可以采用的可能值的数量,同样为第三个和第四个数字选择,直到我最终得到了根据层次信息着色的所有节点。绿色是一种类型,其中某些绿色色调定义了与视觉相似度相对应的某些节点系列。
看来“Analagous”是我想要实现的颜色属性。简单地在 HSV/HSL 方案中定期拆分色调参数是否可以实现此目的,或者是否有更好的方法?
我将用 Python 实现它,但任何算法基本上都应该与语言无关。
I have a network where the nodes are defined hierarchically (via UN SITC coding). In my application, each node has four identifying digits of increasing hierachical specificity (for example, see product 7431) but the network that I've defined is not just the obvious hierachical structure. What I'm trying to do is to color the nodes hierarchically, but lay them out according to my network calculation and see to what extent the two coincide.
Generally speaking, I am looking for a way to generate N color palettes which are as visually distinct as possible from one and other (obviously it's less and less effective as N grows) and then to divide them into sub-palettes until I reach the desired hierarchical depth.
Specifically, that would mean choosing 10 base colors for the first digit and generating palettes of K<=10 colors for each of them where K is the number of possible values that the second digit can assume, and again for the third and fourth digit until I end up with all of the nodes colored according to their hierarchical information. The greens are one type, and within them certain shades of green define certain families of nodes corresponding to visual likeness.
It seems like "Analagous" is the color property that I want to implement. Would simply splitting up the hue parameter regularly in an HSV/HSL scheme accomplish this or is there a better way?
I'll be implementing it in Python but any algorithm should basically be language agnostic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了一个类似的问题(可能与您正在做的事情相反),我正在比较各种图像的光谱输出,以确定基于相似性的排序。
在摆弄 RGB 颜色立方体数周后,我放弃了并转向 HSV - 并且再也没有回头。我会识别那些定义颜色的色调,然后根据它进行排列,这样你就不会有两种有点黄色的颜色 - 相反,你会开始 ax ,然后添加 k 的倍数,这样你就会有这样的东西
:对此,我会少量细分并可能排列“值”和“饱和度”,以增加可用的颜色数量。
如果您最终在系统之间进行转换,我使用 colorsys 没有任何问题。
I tackled a similar problem (likely an inverse of what you're doing) where I was comparing the spectral output of various images to determine an ordering based on similarity.
After many weeks of fiddling with the RGB cube of colors, I gave up and moved to HSV - and never looked back. I would identify those Hues that define colors then permute based on that so that you don't have two kinda-yellow colors - rather, you'd start a x and then add multiples of k so that you'd have something like this:
Within this, I would subdivide and possibly permute the 'value' and 'saturation' by small amounts to increase the number of colors you have available to you.
If you end up converting between systems, I used colorsys with no issues.