I try to understand that how to use arithmetic coding on images. For this, I code on MATLAB. I tell my understanding for arithmetic coding. If I misunderstood to this algorithm, please correct me. After that, I share to my MATLAB code and its error.
- Slice the image using 8*8 macroblock.
- Define range using every pixel value and fit 0 with 1.
- Low and high range value updated for every pixel value.
I understand like this. How to represent with floating point is a better representation. For example my range 0.32423, how to represent this? Other one question is, how to useful this method better than Huffman?
Here is the my code:
clear all
clc
I = [128 75 72 105 149 169 127 100; ...
122 84 83 84 146 138 142 139; ...
118 98 89 94 136 96 143 188; ...
122 106 79 115 148 102 127 167; ...
127 115 106 94 155 124 103 155; ...
125 115 130 140 170 174 115 136; ...
127 110 122 163 175 140 119 87; ...
146 114 127 140 131 142 153 93];
Image = I(:);
prob = zeros(255,1);
comp = arithenco(Image,prob)
Here is the error: