0

Suppose I can define a color c as c = (cr , cg , cb), where cr , cg and cb are floats between 0 and 1 (inclusively).

Suppose I have an input color c and a matrix M of dimensions m×n, whose elements M[i][j] are colors.

How can I organize the elements of M so that I can develop an algorithm that finds the color inside M that is the most similar to c?

Similarity can be measured by euclidian distance or any other metrics.

Ideally, I would not use any data structures in the algorithm, because this is something that is going to run in the GPU and it doesn't use data structures.

Daniel
  • 7,357
  • 7
  • 32
  • 84
  • Could you use a sampler with the colors arranged according to HSL? Two dimensions are not enough to describe a color. – aptriangle Jul 04 '22 at 09:27
  • How big is M likely to be, non-abstractly? – David Eisenstat Jul 04 '22 at 11:06
  • @DavidEisenstat I havent defined it yet, but maybe somewhere around 30 to 50 colors – Daniel Jul 04 '22 at 13:41
  • @aptriangle I guess, maybe... not very familiar with HSL but sounds like an idea – Daniel Jul 04 '22 at 13:42
  • 1
    for 20-50 colors I would use naive linear search ... any advanced method either require "huge" [LUT of reindex values](https://stackoverflow.com/a/30265253/2521214) or have bigger overhead which will gain speed only when number of colors is much bigger – Spektre Jul 05 '22 at 07:04

0 Answers0