产生视觉上不同的颜色与未知彩色系列尺寸 [英] Generate Visually Different Colors With An Unknown Color Collection Size

查看:173
本文介绍了产生视觉上不同的颜色与未知彩色系列尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成的一个图表控件飞色。我要的颜色在视觉上与众不同。我不只是要的颜色是从相邻颜色鲜明,但所有的颜色到目前为止已经产生。

I am trying to generate colors on the fly for a chart control. I want the colors to be visually distinctive. I don't just want the colors to be distinctive from the adjacent colors, but all colors generated so far.

我也不想要有一个已知的颜色集合大小。我已经看到了这方面的一些算法需要多少东西要色被称为。我想实现一个GetNextColor()为我的颜色生成,所以我不知道在选择多少种颜色我最终必须和选择了一些前面的时候觉得不妥。

I also don't want to have to have a known color collection size. Some algorithms I have seen for this require the number of things to color to be known. I want to implement a GetNextColor() for my color generator so I will not know at the time of choosing how many colors I will ultimately have and choosing a number up front feels wrong.

我不只是想绘制一堆东西在不同的颜色,我对这个问题,并希望一些反馈。

I am not just trying to graph a bunch of stuff in different colors, I am interested in this problem and want some feedback.

  • 使用HSV色彩空间。
  • 色相是[0-360],其中0值 和360是相同的(偏红)。
  • 色相从0开始,我的广告27(使 当周围的周期不会降落在相同颜色的它开始 上),采取MOD 360。
  • 对于S和V(包括0和1之间),我开始了在像一个低的数字 0.25
  • 在经过​​约20色调运行
  • 然后采取大量的类似0.85
  • 在经过​​20色调运行
  • 然后开始一分为二,以获得最远距离 那些尚未使用的值。
  • Using the HSV color space.
  • The hue is a value from [0-360] where 0 and 360 are the same (reddish).
  • Hue starts at 0, I ad 27 (so that when it cycles around it doesn't land on the same color it started on), take MOD 360.
  • For S and V (both between 0 and 1) I start out at a low number like .25
  • Run through about 20 hues
  • Then take a high number like .85
  • Run through 20 hues
  • Then start bisecting to get the most distant values that haven't been used yet.

这是不是一个非常有效的方法,它的工作原理确定,但它可能是多少 更加科学。它开始用了很多心思,然后对 演变成这个烂摊子。

This isn't a very effective method, it works OK, but it could be much more scientific. It started out with a lot of thought and then morphed into this mess.

如何优雅地做到这一点任何想法?

(它不应该的问题,但我使用C#和我将发布code,当我回到我的电脑我把所有这些东西上。)

(It shouldn't matter, but I am using C# and I will post code when I get back to my computer I have all this stuff on.)

推荐答案

我认为你的问题应该分为两个问题:

I believe that your question should be split into two questions:

  1. 如何映射色彩到一个n维笛卡尔空间,并定义颜色之间的欧几里德距离函数,使得距离反映了人类观察者的差。
  2. 给定一个n维长方体,生成点的序列,使得迄今生成的任何两个点之间的最小欧几里德距离将最大。

和现在的答案:

  1. 色差正在使用的 CIEDE2000色差公式。该 CIEDE2000公式是根据LCH色彩空间(亮度,色度和色相)。 LCH色彩空间是再presented为一筒(见图片这里)。

  1. Color difference is calculated using the The CIEDE2000 Color-Difference Formula. The CIEDE2000 formula is based on the LCH color space (Luminosity, Chroma, and Hue). LCH color space is represented as a cylinder (see image here).

然而,不同的公式是高度非线性的。因此这将是不可能的颜色映射到一个正方形网格,使得欧几里德距离将使CIEDE2000色差

However, the difference formula is highly nonlinear. Therefore it would be impossible to map the colors into a square grid such that Euclidean distance would give the CIEDE2000 color-difference.

安定在一个不太精确的模型,我们可以使用 CIE76 色差公式,这是基于所述 Lab色空间(L * A * B *)。我们可以直接用在此颜色空间欧几里德距离来测量的差异。有没有简单的公式为RGB或CMYK值和L * a * b *表之间的转换,因为RGB和CMYK颜色模型依赖于设备。的RGB或CMYK值首先需要被转化到特定的绝对颜色空间,诸如sRGB或Adobe RGB。这种调整将是设备相关的,但是从变换所得到的数据将是与设备无关的,允许将数据应变换为CIE 1931颜色空间,然后转化到的L * a * b *表。 文章解释程序和公式。

Settling on a less accurate model, we can use the CIE76 Color-Difference formula, which is based on the Lab color space ( L*a*b*). We can use Euclidean distance directly on this color space to measure the difference. There are no simple formulas for conversion between RGB or CMYK values and L*a*b*, because the RGB and CMYK color models are device dependent. The RGB or CMYK values first need to be transformed to a specific absolute color space, such as sRGB or Adobe RGB. This adjustment will be device dependent, but the resulting data from the transform will be device independent, allowing data to be transformed to the CIE 1931 color space and then transformed into L*a*b*. This article explains the procedure and the formulas.

对于L * A * B颜色空间和CIE76色差公式 - 我们需要解决的问题的3D魔方

For the L*a*b color space and the CIE76 Color-Difference formula - we'll need to solve the problem for a 3D cube.

我认为你最好的策略是分立方体进入8多维数据集,这将生成27分。使用这些点。现在,每8个立方体划分为另外8个立方体。对于每个立方体,12出的27分已经被使用,所以你只剩下15 * 8新的点。在每一个附加步骤N,就可以生成15 * 8的n次方加分。

I believe that your best strategy would be to divide the cube into 8 cubes, which will generate 27 points. Use these points. Now divide each of the 8 cubes into another 8 cubes. For each of these cubes, 12 out of the 27 points have already been used, so you're left with 15*8 new points. In each additional step n, you can generate 15*8^n additional points.

在每个步骤中的点集应被排序,使得两个连续点之间的最小距离将被最大化。我不知道该怎么办呢 - <一个href="http://stackoverflow.com/questions/7731501/sorting-points-such-that-the-minimal-euclidean-distance-between-consecutive-point">I've刚刚发布的问题。

The points-set in each step should be sorted such that the minimal distance between two consecutive points would be maximized. I don't know how to do it - I've just posted a question.

编辑:

我crossposted在 http://cstheory.stackexchange.com/ 并得到了很好的答案。请参阅<一href="http://cstheory.stackexchange.com/questions/8609/sorting-points-such-that-the-minimal-euclidean-distance-between-consecutive-poin">http://cstheory.stackexchange.com/questions/8609/sorting-points-such-that-the-minimal-euclidean-distance-between-consecutive-poin.

I've crossposted on http://cstheory.stackexchange.com/ and got a good answer. See http://cstheory.stackexchange.com/questions/8609/sorting-points-such-that-the-minimal-euclidean-distance-between-consecutive-poin.

这篇关于产生视觉上不同的颜色与未知彩色系列尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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