It's basically a translation from BIZR's update transition, but here you go.
Well, it's not a *perfect* translation, and r/g/b aren't local to anything and are not reset to 0 either (derp). One of those will be the cause of the problem.
Yep, once you translate the += part properly, the result looks the same as FILT.
for x = 0, 11 do
r = r + bit.band(bit.rshift(ctype, x + 18), 1)
g = g + bit.band(bit.rshift(ctype, x + 9), 1)
b = b + bit.band(bit.rshift(ctype, x ), 1)
end