So I'm looking for a bit of an abstract algorithm and I'd appreciate any references to read up on. This is a bit tough to explain but I'll try my best.
Suppose we have 2 arrays of RGB
pixel tuples-
A -> {(56, 39, 75), (125, 222, 32), (156, 201, 102)}
B -> {(125, 195, 93), (53, 31, 67), (118, 219, 48)}
I'd like the sort the second array in such a way that for each index of the 2 arrays, the corresponding RGB tuple pairs have the least deviation in value such that the optical difference between the 2 tuples is imperceptible to the human eye. For example, the difference between (122, 36, 18) and (126, 31, 25) is imperceptible, this is what we want.
For the example arrays A and B, I think sorting B like so will keep the arrays as optically identical as possible-
{(53, 31, 67), (118, 219, 48), (125, 195, 93)}
Constraints
- Both arrays are of same length
- The RGB pixel tuples themselves must remain unchanged, only their order in the array should be changed.
- The first array must remain unchanged, only the second should be sorted accordingly
- There may not be enough optimal elements in the second array to provide a perfect/good match, in this case the least amount of sacrifices will be preferred. The end goal is for the new pixel array to be as identical to the original array as possible. The least amount of sacrifices will ensure that the arrays of pixels, when turned into a picture, will look as identical as possible. Note: By the word "sacrifice", I mean when the deviation in 2 pixel tuples is enough for the human eye to notice a difference.
|value1 - value2|
. I edited my question to add some explaination $\endgroup$ – Chase Feb 3 '20 at 5:09