Flora TCS34725 LUT algorithm

I'm trying to get better results using TCS34725 sensor for my color-view project. The sensor's non-linearity got me into a lot of troubles. The best solution I figured out was creating a look-up table for matching the colors. The number of colors stored it's not relevant. It can be 64, 256, 1024. I managed to store the values of colors (generated by me) that sensor is returning and their real values. I can make an algoritm for this lut that works only if I scan a stored value from it. Now what I'm trying to manage it's a "middle" situation when I scan a color that it's not stored in table, but it can be found between 2 stored colors. What I want this algorithm to do is to find the closest matching color from table for that color.
I have 6 vectors with values: 3 vectors with real values and 3 vectors with returned values of sensor for those real values.
realR = { x , a ... }
realG = { y , b ... }
realB = { z , c ... }
returnedR = { x' , a'... }
returnedG = { y' , b'... }
returnedB = { z' , c'... }
First real color values are (R G B) : x - y - z
First returned color values are (R G B) : x' - y' - z'
Second real color values are (R G B) : a - b - c
Second returned color values are (R G B) : a' - b' - c'
For example Blue (0-0-255) it's returned as (40-90-180) (R-G-B)
I used this gradient progress bar for generating the color (not this literally but i generated samples from it on desktop screen)


Or maybe is there anyone who has a better idea than a lut?
Sorry for bad english btw

The number of colors stored it's not relevant.

Absolute nonsense.

The whole point of a lookup table is to find the value(s) that are closest to the index value when the index value is NOT in the table. If you need help writing the code that looks up the value(s) in the table, you have to do more than wave your arms uselessly.

Post your code. In code tags.