My goal is a more efficient implementation of the algorithm posed in this matter .
Consider two sets of points (in N-space. 3-space for the approximate case of the RGB color space, while the solution for 1-space 2-space is different only when calculating the distance). How do you find the point in the first set that is farthest from the nearest neighbor in the second set?
In the example with 1 space, given the sets A: {2,4,6,8} and B: {1,3,5}, the answer is 8, since 8 is 3 units from 5 (the closest neighbor is in B) , and all other members of A are only 1 unit from their nearest neighbor in B. edit: 1-space is too simplified, since sorting is related to distance so that it is not in higher dimensions.
The solution in the original question involves comparing the brute force of each point in one set (all R, G, B, where 512> = R + G + B> = 256 and R% 4 = 0 and G% 4 = 0 and B% 4 = 0) to each point of another set (colorTable). Ignore, for the sake of this question, that the first set is designed programmatically and not repeated as a saved list, such as the second set.
Sparr source
share