指数哥伦布码
外观
指數哥倫布碼(Exponential-Golomb coding)是一种无损数据压缩方法。
用来表示非负整数的k阶指数哥伦布码可用如下步骤生成:
- 将数字以二进制形式写出(B),去掉最低的k个位元(D),之后加1 (A = B + 1)
- 计算A的比特個数(C),将此数减一,即是需要增加的前导零个数(Z = C -1)
- 将第一步中去掉的最低k个比特位补回比特串尾部 (ExpG = Z個0 + A + D)
0阶指数哥伦布码如下所示:
Step 1 Step 2 Step 3 0 => B = 0 ,D = None, A = 1 => C = 1 , Z = 0 => 1 1 => B = 1 ,D = None, A = 10 => C = 2 , Z = 1 => 010 2 => B = 10 ,D = None ,A = 11 => C = 2 , Z = 1 => 011 3 => B = 11 ,D = None ,A = 100 => C = 3 , Z = 2 => 00100 4 => B = 100 ,D = None ,A = 101 => C = 3 , Z = 2 => 00101 5 => B = 101 ,D = None ,A = 110 => C = 3 , Z = 2 => 00110 6 => B = 110 ,D = None ,A = 111 => C = 3 , Z = 2 => 00111 7 => B = 111 ,D = None ,A = 1000 => C = 4 , Z = 3 => 0001000 8 => B = 1000,D = None ,A = 1001 => C = 4 , Z = 3 => 0001001
以數字9為例, (1)2進制值B 為1001,因為K為0階,去除0個位元,故D值為空,把B值加1 得到 A,值為 1010, (2)計算A的位元個數,得到C值為4,故減1後得到前導零Z ,值為3 (3)最後組合 Z + A + D之後,得到 000+1010 + 空 ,故Exp-G值為 0001010
1阶指数哥伦布码如下所示:
Step 1 Step 2 Step 3 0 => B = 0 ,D = 0 , A = 1 => C = 1 , Z = 0 => 10 1 => B = 1 ,D = 1 , A = 1 => C = 1 , Z = 0 => 11 2 => B = 10 ,D = 0 , A = 10 => C = 2 , Z = 1 => 0100 3 => B = 11 ,D = 1 , A = 10 => C = 2 , Z = 1 => 0101 4 => B = 100 ,D = 0 , A = 11 => C = 2 , Z = 1 => 0110 5 => B = 101 ,D = 1 , A = 11 => C = 2 , Z = 1 => 0111 6 => B = 110 ,D = 0 , A = 100 => C = 3 , Z = 2 => 001000 7 => B = 111 ,D = 1 , A = 100 => C = 3 , Z = 2 => 001001 8 => B = 1000,D = 0 , A = 101 => C = 3 , Z = 2 => 001010