Very Parallel VQ Solution
Why not perform all codebook lookup’s at once?
region R = [1..n,1..n,0..255];
-- read in code book, flood into first 2 dimensions
[R] repeat
-- Input blocked image as 1st plane of Im
[1..n,1..n,*] Imrep := >>[,,1] Im;
Temp := dist(CB,Imrep);
Coding := max<<(Index3*(Temp = max<<Temp));
-- Output the compressed image in Coding