# Arithmetic coding of images

How does arithmetic coding work with images? I understand how it works with textual messages but I don't understand how it works with images.

So with textual data, we use the probabilities of the symbols to divide the interval between 0 and 1 into subintervals and then at each round we choose one of the intervals to be the new interval.

For example, we can code the word "wiki" with fractional value 0.001011 (decimal 0.172). (https://en.wikipedia.org/wiki/Arithmetic_coding)

With images, do we partition the image into subimages? For example 10x10 blocks. Then we count the probabilities of each pixel value in that block and use that as our model. Then subdivide the interval from 0 to 1 into 100 subintervals according to the probabilities. Then we choose one of the subintervals as the new interval, depending on which symbol (pixel value) we are coding? So the pixel values are the symbols and the probabilities of each symbol is the model. Finally, one fractional number represents the whole block of pixels, i. e. 100 pixels.

The reason why I think that we have to partition the image into blocks is that it would result in a huge model if we have to count the probabilities of every pixel value of an image where a pixel can take any value between 0 and 255. Also we should have to subdivide the interval [0, 1) into a huge amount of subintervals. And the final fractional value would require a lot of bits if it would represent an entire image.