> First, I keep testing all 16 possible R changes, G and B. And then, I try to find an even better solution using the current palette.
> It means 64 color distances to compute
Isn't it unnecessary to test all 16 R, G, and B values? I know the title of the post says "brute force", but you already know the desired R, G, or B value, and any other value seems guaranteed to have a larger color distance. (The distance function is subtracts actual R from desired R, right?)
Seems like you could compute only 19 color distance instead of 64: the closest R, G, and B plus the 16 palette entries.
> It means 64 color distances to compute
Isn't it unnecessary to test all 16 R, G, and B values? I know the title of the post says "brute force", but you already know the desired R, G, or B value, and any other value seems guaranteed to have a larger color distance. (The distance function is subtracts actual R from desired R, right?)
Seems like you could compute only 19 color distance instead of 64: the closest R, G, and B plus the 16 palette entries.