[英]Is there a better than O(N^2) Algorithm to take a set of colors and return colors that contrast or are dissimilar?
I am trying to come up with an algorithm that can take a set of colors X and return a new set of colors X' that consists of only contrasting colors from the original set X. In other words I want to filter out similar colors from the passed in color set. 我正在尝试提出一种算法,该算法可以采用一组颜色X并返回一组新的颜色X',该组颜色X'仅包含原始组X中的对比色。换句话说,我想从中过滤掉相似的颜色通过颜色设置。 If you would like to think in terms of color differencing, the problem can be thought of filtering out all colors that are <= some distance k from any color in the set. 如果要考虑颜色差异,可以考虑将所有颜色与集合中的任何颜色相距小于或等于k的所有颜色过滤掉。
Does anyone know of a way to do this in linear time or O(N). 有谁知道在线性时间或O(N)中执行此操作的方法。 I am ok with other time complexities as well as long as it is not O(N^2), every solution I come up with takes polynomial time. 只要不是O(N ^ 2),我对其他时间复杂度都可以,我想出的每个解决方案都需要多项式时间。 I tried reducing the problem to the famous "find all pairs of integers in an array that sum to K" but that reduction did not work. 我尝试将问题简化为著名的“在数组中求和为K的所有整数对”,但这种归零法不起作用。 I am using the deltaE metric to determine how far apart or dissimilar/contrasting two colors are. 我正在使用deltaE度量标准来确定两种颜色之间的距离或相异/对比度。
Use a cover tree to store colors under the ∆E metric. 使用覆盖树将颜色存储在∆E度量标准之下。 For each color, do an O(log n)-time proximity search in the cover tree and reject it if the nearest color is too close. 对于每种颜色,在覆盖树中进行O(log n)次接近搜索,如果最接近的颜色过于接近,则拒绝它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.