Search code examples
matlabimage-processingjpeglibjpegdct

How does Phil Sallee's jpeg toolbox divide images in the coef_arrays?


How does the toolbox divides images into blocks in the coef_arrays?

I have a 225x225 image. But the coef_arrays gave three 232x232 double arrays.

With a 160x100 image, I get one 104x168 double array and two 56x88 double arrays.

Why am i getting array dimensions more than the image size? Am i not supposed to get a total of 225x225 or 160x100 arrays no matter how many blocks the image is divided?

Say 225x225 into 10 blocks would be 11 20x20 arrays and 1 5x5 array.


Solution

  • JPEG compresses in blocks of 8x8. If you have an image whose size is not a multiple of 8, the encoder has to expand the image to a multiple of 8.

    So 225x225 gets expanded into 232x232 with one array for each color component.

    For the 160x100 image you are apparently using 2:1 of the Cb and Cr components.

    I am not sure why you are getting the sizes you are getting. 160x100 could go to 160x104 (not 168x104) and 80x5o could go to 80x56.