title: How Huffman Encoding construct the image(jpeg) from dct coefficients?
body: <p>I have a 512x512 image and I tried to recompress it. Here's the steps for recompressing an image to jpeg file</p>
  
  <pre><code>    1) convert rgb to YCrCb
      2) perform down sampling on Cr and Cb
      2) convert YCrCb to DCT and Quantized according to chosen Quality
      3) perform Huffman Encoding on Quantized DCT
  </code></pre>
  
  <p>But before Huffman Encoding I counted the number of DCT coefficients and it is 393216. Dividing by it by 64 tells me the number of DCT block (8x8) which will be 6144.</p>
  
  <p>Now I tried to count the number of 8x8 blocks for pixel domain. 512/8=64 which gives me 64 blocks horizontally and 64 blocks vertically. 64 x 64 = 4096 which is not equal to number of DCT blocks while the number of pixels are 512x512 = 262144</p>
  
  <p>My Question is how does Huffman encoding magically transform 393216 coefficients to 262144 pixels and get each pixel values, and compute the dimension (512x512) of the compressed image(jpeg).</p>
  
  <p>Thanks you in advance. :D</p>